diff --git a/src/Flecs.NET.Bindings/Flecs.NET.Bindings.csproj b/src/Flecs.NET.Bindings/Flecs.NET.Bindings.csproj index d0308683..e898054b 100644 --- a/src/Flecs.NET.Bindings/Flecs.NET.Bindings.csproj +++ b/src/Flecs.NET.Bindings/Flecs.NET.Bindings.csproj @@ -10,7 +10,7 @@ true true - 4.0.0 + 4.0.1 Flecs.NET.Bindings.Debug Flecs.NET.Bindings.Release BeanCheeseBurrito diff --git a/src/Flecs.NET.Bindings/Flecs.g.cs b/src/Flecs.NET.Bindings/Flecs.g.cs index a78d92db..a18efd0f 100644 --- a/src/Flecs.NET.Bindings/Flecs.g.cs +++ b/src/Flecs.NET.Bindings/Flecs.g.cs @@ -202,9 +202,6 @@ public static unsafe partial class flecs [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_entity_from_json", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern byte* ecs_entity_from_json(ecs_world_t* world, ulong entity, byte* json, ecs_from_json_desc_t* desc); - [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_entity_from_json_legacy", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern byte* ecs_entity_from_json_legacy(ecs_world_t* world, ulong entity, byte* json, ecs_from_json_desc_t* desc); - [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_entity_init", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern ulong ecs_entity_init(ecs_world_t* world, ecs_entity_desc_t* desc); @@ -223,32 +220,35 @@ public static unsafe partial class flecs [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_exists", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern byte ecs_exists(ecs_world_t* world, ulong entity); + [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_field_at_w_size", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] + public static extern void* ecs_field_at_w_size(ecs_iter_t* it, System.IntPtr size, byte index, int row); + [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_field_column", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern int ecs_field_column(ecs_iter_t* it, int index); + public static extern int ecs_field_column(ecs_iter_t* it, byte index); [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_field_id", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern ulong ecs_field_id(ecs_iter_t* it, int index); + public static extern ulong ecs_field_id(ecs_iter_t* it, byte index); [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_field_is_readonly", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern byte ecs_field_is_readonly(ecs_iter_t* it, int index); + public static extern byte ecs_field_is_readonly(ecs_iter_t* it, byte index); [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_field_is_self", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern byte ecs_field_is_self(ecs_iter_t* it, int index); + public static extern byte ecs_field_is_self(ecs_iter_t* it, byte index); [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_field_is_set", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern byte ecs_field_is_set(ecs_iter_t* it, int index); + public static extern byte ecs_field_is_set(ecs_iter_t* it, byte index); [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_field_is_writeonly", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern byte ecs_field_is_writeonly(ecs_iter_t* it, int index); + public static extern byte ecs_field_is_writeonly(ecs_iter_t* it, byte index); [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_field_size", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern System.IntPtr ecs_field_size(ecs_iter_t* it, int index); + public static extern System.IntPtr ecs_field_size(ecs_iter_t* it, byte index); [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_field_src", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern ulong ecs_field_src(ecs_iter_t* it, int index); + public static extern ulong ecs_field_src(ecs_iter_t* it, byte index); [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_field_w_size", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern void* ecs_field_w_size(ecs_iter_t* it, System.IntPtr size, int index); + public static extern void* ecs_field_w_size(ecs_iter_t* it, System.IntPtr size, byte index); [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_fini", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern int ecs_fini(ecs_world_t* world); @@ -1348,6 +1348,9 @@ public static unsafe partial class flecs [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_table_count", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern int ecs_table_count(ecs_table_t* table); + [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_table_entities", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] + public static extern ulong* ecs_table_entities(ecs_table_t* table); + [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_table_find", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern ecs_table_t* ecs_table_find(ecs_world_t* world, ulong* ids, int id_count); @@ -1384,6 +1387,9 @@ public static unsafe partial class flecs [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_table_remove_id", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern ecs_table_t* ecs_table_remove_id(ecs_world_t* world, ecs_table_t* table, ulong id); + [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_table_size", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] + public static extern int ecs_table_size(ecs_table_t* table); + [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_table_str", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern byte* ecs_table_str(ecs_world_t* world, ecs_table_t* table); @@ -1558,12 +1564,6 @@ public static unsafe partial class flecs [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_world_from_json_file", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern byte* ecs_world_from_json_file(ecs_world_t* world, byte* filename, ecs_from_json_desc_t* desc); - [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_world_from_json_file_legacy", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern byte* ecs_world_from_json_file_legacy(ecs_world_t* world, byte* filename, ecs_from_json_desc_t* desc); - - [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_world_from_json_legacy", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern byte* ecs_world_from_json_legacy(ecs_world_t* world, byte* json, ecs_from_json_desc_t* desc); - [System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, EntryPoint = "ecs_world_stats_copy_last", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern void ecs_world_stats_copy_last(ecs_world_stats_t* dst, ecs_world_stats_t* src); @@ -2864,7 +2864,7 @@ public partial struct ecs_each_iter_t : System.IEquatable public int columns; - public void* ptrs; + public ecs_table_record_t* trs; public bool Equals(ecs_each_iter_t other) { @@ -4370,8 +4370,6 @@ public partial struct ecs_iter_t : System.IEquatable public ulong* entities; - public void** ptrs; - public int* sizes; public ecs_table_t* table; @@ -4382,7 +4380,7 @@ public partial struct ecs_iter_t : System.IEquatable public ecs_var_t* variables; - public int* columns; + public ecs_table_record_t** trs; public ulong* sources; @@ -4390,11 +4388,11 @@ public partial struct ecs_iter_t : System.IEquatable public ulong group_id; - public int field_count; - public uint set_fields; - public uint shared_fields; + public uint ref_fields; + + public uint row_fields; public uint up_fields; @@ -4406,11 +4404,13 @@ public partial struct ecs_iter_t : System.IEquatable public int event_cur; - public ecs_query_t* query; + public byte field_count; + + public byte term_index; - public int term_index; + public byte variable_count; - public int variable_count; + public ecs_query_t* query; public byte** variable_names; @@ -4720,6 +4720,8 @@ public partial struct ecs_member_t : System.IEquatable public ulong unit; + public byte use_offset; + public ecs_member_value_range_t range; public ecs_member_value_range_t error_range; @@ -5326,7 +5328,7 @@ public partial struct ecs_observer_desc_t : System.IEquatable public uint flags; - public short var_count; + public byte var_count; public byte term_count; @@ -6421,6 +6423,8 @@ public partial struct ecs_query_t : System.IEquatable public uint read_fields; + public uint row_fields; + public uint shared_readonly_fields; public uint set_fields; @@ -8162,46 +8166,50 @@ public override int GetHashCode() } } - public partial struct ecs_table_cache_iter_t : System.IEquatable + public partial struct ecs_table_cache_hdr_t : System.IEquatable { - public ecs_table_cache_hdr_t* cur; + public ecs_table_cache_t* cache; + + public ecs_table_t* table; + + public ecs_table_cache_hdr_t* prev; public ecs_table_cache_hdr_t* next; - public ecs_table_cache_hdr_t* next_list; + public byte empty; - public partial struct ecs_table_cache_hdr_t : System.IEquatable + public partial struct ecs_table_cache_t : System.IEquatable { - public bool Equals(ecs_table_cache_hdr_t other) + public bool Equals(ecs_table_cache_t other) { - fixed (ecs_table_cache_hdr_t* __self = &this) + fixed (ecs_table_cache_t* __self = &this) { - return System.MemoryExtensions.SequenceEqual(new System.ReadOnlySpan((byte*)__self, sizeof(ecs_table_cache_hdr_t)), new System.ReadOnlySpan((byte*)&other, sizeof(ecs_table_cache_hdr_t))); + return System.MemoryExtensions.SequenceEqual(new System.ReadOnlySpan((byte*)__self, sizeof(ecs_table_cache_t)), new System.ReadOnlySpan((byte*)&other, sizeof(ecs_table_cache_t))); } } public override bool Equals(object? obj) { - return obj is ecs_table_cache_hdr_t other && Equals(other); + return obj is ecs_table_cache_t other && Equals(other); } - public static bool operator ==(ecs_table_cache_hdr_t left, ecs_table_cache_hdr_t right) + public static bool operator ==(ecs_table_cache_t left, ecs_table_cache_t right) { return left.Equals(right); } - public static bool operator !=(ecs_table_cache_hdr_t left, ecs_table_cache_hdr_t right) + public static bool operator !=(ecs_table_cache_t left, ecs_table_cache_t right) { return !(left == right); } public override int GetHashCode() { - fixed (ecs_table_cache_hdr_t* __self = &this) + fixed (ecs_table_cache_t* __self = &this) { #if NET6_0_OR_GREATER System.HashCode hash = new System.HashCode(); - hash.AddBytes(new System.ReadOnlySpan((byte*)__self, sizeof(ecs_table_cache_hdr_t))); + hash.AddBytes(new System.ReadOnlySpan((byte*)__self, sizeof(ecs_table_cache_t))); return hash.ToHashCode(); #else return base.GetHashCode(); @@ -8210,6 +8218,52 @@ public override int GetHashCode() } } + public bool Equals(ecs_table_cache_hdr_t other) + { + fixed (ecs_table_cache_hdr_t* __self = &this) + { + return System.MemoryExtensions.SequenceEqual(new System.ReadOnlySpan((byte*)__self, sizeof(ecs_table_cache_hdr_t)), new System.ReadOnlySpan((byte*)&other, sizeof(ecs_table_cache_hdr_t))); + } + } + + public override bool Equals(object? obj) + { + return obj is ecs_table_cache_hdr_t other && Equals(other); + } + + public static bool operator ==(ecs_table_cache_hdr_t left, ecs_table_cache_hdr_t right) + { + return left.Equals(right); + } + + public static bool operator !=(ecs_table_cache_hdr_t left, ecs_table_cache_hdr_t right) + { + return !(left == right); + } + + public override int GetHashCode() + { + fixed (ecs_table_cache_hdr_t* __self = &this) + { +#if NET6_0_OR_GREATER + System.HashCode hash = new System.HashCode(); + hash.AddBytes(new System.ReadOnlySpan((byte*)__self, sizeof(ecs_table_cache_hdr_t))); + return hash.ToHashCode(); +#else + return base.GetHashCode(); +#endif + } + } + } + + public partial struct ecs_table_cache_iter_t : System.IEquatable + { + public ecs_table_cache_hdr_t* cur; + + public ecs_table_cache_hdr_t* next; + + public ecs_table_cache_hdr_t* next_list; + public bool Equals(ecs_table_cache_iter_t other) { fixed (ecs_table_cache_iter_t* __self = &this) @@ -8296,6 +8350,14 @@ public override int GetHashCode() public partial struct ecs_table_record_t : System.IEquatable { + public ecs_table_cache_hdr_t hdr; + + public short index; + + public short count; + + public short column; + public bool Equals(ecs_table_record_t other) { fixed (ecs_table_record_t* __self = &this) @@ -8434,7 +8496,7 @@ public partial struct ecs_term_t : System.IEquatable public short oper; - public short field_index; + public byte field_index; public ushort flags_; @@ -10252,6 +10314,8 @@ public partial struct EcsMember : System.IEquatable public int offset; + public byte use_offset; + public bool Equals(EcsMember other) { fixed (EcsMember* __self = &this) @@ -11852,6 +11916,8 @@ public enum ecs_type_kind_t : uint public const uint EcsIdIsSparse = 16777216; + public const uint EcsIdIsTransitive = 16384; + public const uint EcsIdIsUnion = 33554432; public const uint EcsIdMarkedForDelete = 1073741824; @@ -11924,12 +11990,8 @@ public enum ecs_type_kind_t : uint public const uint EcsIterTrivialSearch = 256; - public const uint EcsIterTrivialSearchNoData = 512; - public const uint EcsIterTrivialTest = 2048; - public const uint EcsIterTrivialTestNoData = 4096; - public const int EcsIterYield = -1; public const uint EcsObserverBypassQuery = 32; @@ -11970,8 +12032,6 @@ public enum ecs_type_kind_t : uint public const uint EcsQueryHasScopes = 131072; - public const uint EcsQueryHasSparseThis = 67108864; - public const uint EcsQueryHasTableThisVar = 33554432; public const uint EcsQueryIsCacheable = 16777216; @@ -11992,8 +12052,6 @@ public enum ecs_type_kind_t : uint public const uint EcsQueryMatchWildcards = 16384; - public const uint EcsQueryNoData = 16; - public const uint EcsQueryTableOnly = 128; public const ulong EcsSelf = 9223372036854775808; @@ -12082,8 +12140,6 @@ public enum ecs_type_kind_t : uint public const uint EcsTermMatchAnySrc = 2; - public const uint EcsTermNoData = 64; - public const ulong EcsTermRefFlags = 18374686479671623680; public const uint EcsTermReflexive = 8; @@ -12124,14 +12180,14 @@ public enum ecs_type_kind_t : uint public const int flecs_iter_cache_all = 255; - public const uint flecs_iter_cache_columns = 2; - public const uint flecs_iter_cache_ids = 1; public const uint flecs_iter_cache_ptrs = 8; public const uint flecs_iter_cache_sources = 4; + public const uint flecs_iter_cache_trs = 2; + public const uint flecs_iter_cache_variables = 16; public const int FLECS_QUERY_SCOPE_NESTING_MAX = 8; @@ -12148,13 +12204,13 @@ public enum ecs_type_kind_t : uint public const int FLECS_VARIABLE_COUNT_MAX = 64; - public const string FLECS_VERSION = "4.0.0"; + public const string FLECS_VERSION = "4.0.1"; public const int FLECS_VERSION_MAJOR = 4; public const int FLECS_VERSION_MINOR = 0; - public const int FLECS_VERSION_PATCH = 0; + public const int FLECS_VERSION_PATCH = 1; private static void* ECS_AUTO_OVERRIDE_Ptr; diff --git a/src/Flecs.NET.Codegen/Generators/IIterable.cs b/src/Flecs.NET.Codegen/Generators/IIterable.cs index 01475e62..d6fd3aa2 100644 --- a/src/Flecs.NET.Codegen/Generators/IIterable.cs +++ b/src/Flecs.NET.Codegen/Generators/IIterable.cs @@ -103,6 +103,7 @@ public static string GenerateExtensions(Type type, int i) public {{Generator.GetInvokerReturnType(callback)}} {{Generator.GetInvokerName(callback)}}({{Generator.GetCallbackType(callback, i)}} callback) { {{Generator.GetTypeName(Type.TypeHelper, i)}}.AssertReferenceTypes({{(Generator.GetCallbackIsUnmanaged(callback) ? "false" : "true")}}); + {{Generator.GetTypeName(Type.TypeHelper, i)}}.AssertSparseTypes(Ecs.GetIterableWorld(ref this), {{(Generator.GetCallbackIsIter(callback) ? "false" : "true")}}); {{Generator.GetInvokerReturn(callback)}}Invoker.{{Generator.GetInvokerName(callback)}}(ref this, callback); } """); diff --git a/src/Flecs.NET.Codegen/Generators/Invoker.cs b/src/Flecs.NET.Codegen/Generators/Invoker.cs index b90556b8..85933c7e 100644 --- a/src/Flecs.NET.Codegen/Generators/Invoker.cs +++ b/src/Flecs.NET.Codegen/Generators/Invoker.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -43,7 +44,7 @@ private static string GenerateIterIteratorInvokers(int i) public static void Iter<{{Generator.TypeParameters[i]}}>(Iter it, {{Generator.GetCallbackType(callback, i)}} callback) { Ecs.TableLock(it); - callback(it, {{Generator.GetCallbackArguments(i, callback)}}); + callback(it, {{Generator.GetCallbackArguments(callback, i)}}); Ecs.TableUnlock(it); } """); @@ -74,19 +75,45 @@ private static string GenerateEachIteratorInvokers(int i) { {{Generator.GetCallbackCountVariable(callback)}} - {{Generator.IterPointerVariables[i]}} - {{Generator.IterStepVariables[i]}} + {{Generator.FieldDataVariables[i]}} + IterationTechnique flags = it.GetIterationTechnique({{i + 1}}); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, {{Generator.IterPointerIncrements[i]}}) - callback({{Generator.GetCallbackSteppedArguments(i, callback)}}); + + if ({{Generator.ContainsReferenceTypes[i]}}) + { + if (flags == IterationTechnique.None) + {{IterationTechnique.Managed}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == IterationTechnique.Shared) + {{IterationTechnique.SharedManaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == IterationTechnique.Sparse) + {{IterationTechnique.SparseManaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + {{IterationTechnique.SparseSharedManaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + } + else + { + if (flags == IterationTechnique.None) + {{IterationTechnique.Unmanaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == IterationTechnique.Shared) + {{IterationTechnique.SharedUnmanaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == IterationTechnique.Sparse) + {{IterationTechnique.SparseUnmanaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + {{IterationTechnique.SparseSharedUnmanaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + } Ecs.TableUnlock(it); + + return; + + {{GenerateEachInvokerIterators(callback, i)}} } """); return $$""" + using System; + using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -112,29 +139,47 @@ private static string GenerateFindIteratorInvokers(int i) { {{Generator.GetCallbackCountVariable(callback)}} - {{Generator.IterPointerVariables[i]}} - {{Generator.IterStepVariables[i]}} + {{Generator.FieldDataVariables[i]}} + IterationTechnique flags = it.GetIterationTechnique({{i + 1}}); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, {{Generator.IterPointerIncrements[i]}}) + + if ({{Generator.ContainsReferenceTypes[i]}}) { - if (!callback({{Generator.GetCallbackSteppedArguments(i, callback)}})) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = {{IterationTechnique.Managed}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == IterationTechnique.Shared) + result = {{IterationTechnique.SharedManaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == IterationTechnique.Sparse) + result = {{IterationTechnique.SparseManaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = {{IterationTechnique.SparseSharedManaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + } + else + { + if (flags == IterationTechnique.None) + result = {{IterationTechnique.Unmanaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == IterationTechnique.Shared) + result = {{IterationTechnique.SharedUnmanaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == IterationTechnique.Sparse) + result = {{IterationTechnique.SparseUnmanaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = {{IterationTechnique.SparseSharedUnmanaged}}(it, count, callback, {{Generator.FieldDataRefs[i]}}); } Ecs.TableUnlock(it); return result; + + {{GenerateFindInvokerIterators(callback, i)}} } """); return $$""" + using System; + using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -147,6 +192,39 @@ public static unsafe partial class Invoker """; } + private static string GenerateEachInvokerIterators(Callback callback, int i) + { + IEnumerable invokerIterators = Enum.GetValues(typeof(IterationTechnique)).Cast().Select((IterationTechnique iterationTechnique) => $$""" + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void {{iterationTechnique}}(Iter it, int count, {{Generator.GetCallbackType(callback, i)}} callback, {{Generator.FieldDataParameters[i]}}) + { + for (int i = 0; i < count; i++) + callback({{Generator.GetCallbackArguments(callback, iterationTechnique, i)}}); + } + """); + + return string.Join(Separator.DoubleNewLine, invokerIterators); + } + + private static string GenerateFindInvokerIterators(Callback callback, int i) + { + IEnumerable invokerIterators = Enum.GetValues(typeof(IterationTechnique)).Cast().Select((IterationTechnique iterationTechnique) => $$""" + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity {{iterationTechnique}}(Iter it, int count, {{Generator.GetCallbackType(callback, i)}} callback, {{Generator.FieldDataParameters[i]}}) + { + for (int i = 0; i < count; i++) + { + if (callback({{Generator.GetCallbackArguments(callback, iterationTechnique, i)}})) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + """); + + return string.Join(Separator.DoubleNewLine, invokerIterators); + } + private static string GenerateIterIterableInvokers(int i) { IEnumerable invokers = Generator.CallbacksIter.Select((Callback callback) => $$""" @@ -279,7 +357,7 @@ public static string GenerateFetchComponentInvokers(int i) bool hasComponents = Ecs.GetPointers<{{Generator.TypeParameters[i]}}>(world, entity, record, table, pointers); if (hasComponents) - callback({{Generator.GetCallbackArguments(i, callback)}}); + callback({{Generator.GetCallbackArguments(callback, i)}}); ecs_{{Generator.GetInvokerName(callback).ToLower()}}_end(record); @@ -347,7 +425,7 @@ public static string GenerateFetchComponentInvokers(int i) Ecs.EnsurePointers<{{Generator.TypeParameters[i]}}>(world, entity, pointers); } - callback({{Generator.GetCallbackArguments(i, callback)}}); + callback({{Generator.GetCallbackArguments(callback, i)}}); if (!world.IsDeferred()) Ecs.TableUnlock(world, table); diff --git a/src/Flecs.NET.Codegen/Generators/IterIterable.cs b/src/Flecs.NET.Codegen/Generators/IterIterable.cs index 2416d837..94e7139d 100644 --- a/src/Flecs.NET.Codegen/Generators/IterIterable.cs +++ b/src/Flecs.NET.Codegen/Generators/IterIterable.cs @@ -172,6 +172,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct {{Generator.GetTypeName(Type.IterIterable, i)}} : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET.Codegen/Generators/NodeBuilder.cs b/src/Flecs.NET.Codegen/Generators/NodeBuilder.cs index 584d2081..992a711c 100644 --- a/src/Flecs.NET.Codegen/Generators/NodeBuilder.cs +++ b/src/Flecs.NET.Codegen/Generators/NodeBuilder.cs @@ -17,6 +17,7 @@ public static string GenerateExtensions(Type builderType, Type returnType, int i public {{Generator.GetTypeName(returnType, i)}} {{Generator.GetInvokerName(callback)}}({{Generator.GetCallbackType(callback, i)}} callback) { {{Generator.GetTypeName(Type.TypeHelper, i)}}.AssertReferenceTypes({{(Generator.GetCallbackIsUnmanaged(callback) ? "false" : "true")}}); + {{Generator.GetTypeName(Type.TypeHelper, i)}}.AssertSparseTypes(World, {{(Generator.GetCallbackIsIter(callback) ? "false" : "true")}}); return {{(Generator.GetCallbackIsRun(callback) ? "SetRun" : "SetCallback")}}({{(Generator.GetCallbackIsDelegate(callback) ? string.Empty : "(IntPtr)")}}callback, Pointers<{{Generator.TypeParameters[i]}}>.{{callback}}).Build(); } """); diff --git a/src/Flecs.NET.Codegen/Generators/PageIterable.cs b/src/Flecs.NET.Codegen/Generators/PageIterable.cs index 9a7c820d..c04bfd94 100644 --- a/src/Flecs.NET.Codegen/Generators/PageIterable.cs +++ b/src/Flecs.NET.Codegen/Generators/PageIterable.cs @@ -85,6 +85,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct {{Generator.GetTypeName(Type.PageIterable, i)}} : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET.Codegen/Generators/Query.cs b/src/Flecs.NET.Codegen/Generators/Query.cs index 76ba875d..c844ad31 100644 --- a/src/Flecs.NET.Codegen/Generators/Query.cs +++ b/src/Flecs.NET.Codegen/Generators/Query.cs @@ -221,6 +221,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct {{Generator.GetTypeName(Type.Query, i)}} : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET.Codegen/Generators/TypeHelper.cs b/src/Flecs.NET.Codegen/Generators/TypeHelper.cs index 548ab4b7..13a1699c 100644 --- a/src/Flecs.NET.Codegen/Generators/TypeHelper.cs +++ b/src/Flecs.NET.Codegen/Generators/TypeHelper.cs @@ -27,11 +27,14 @@ public static string GenerateTypeHelper(int i) using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; + using Flecs.NET.Utilities; + + using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] - internal static partial class {{Generator.GetTypeName(Type.TypeHelper, i)}} + internal static unsafe partial class {{Generator.GetTypeName(Type.TypeHelper, i)}} { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ {{Generator.TypeFullNames[i]}} ]; @@ -39,17 +42,20 @@ internal static partial class {{Generator.GetTypeName(Type.TypeHelper, i)}} public static readonly int Tags = {{Generator.Tags[i]}}; public static readonly int ReferenceTypes = {{Generator.ReferenceTypes[i]}}; + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, {{i + 1}}) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, {{i + 1}}) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -58,11 +64,21 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, {{i + 1}}) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = {{Generator.SparseBitField[i]}}; + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } """; diff --git a/src/Flecs.NET.Codegen/Generators/WorkerIterable.cs b/src/Flecs.NET.Codegen/Generators/WorkerIterable.cs index ee60c28b..9081e710 100644 --- a/src/Flecs.NET.Codegen/Generators/WorkerIterable.cs +++ b/src/Flecs.NET.Codegen/Generators/WorkerIterable.cs @@ -85,6 +85,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct {{Generator.GetTypeName(Type.WorkerIterable, i)}} : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET.Codegen/Helpers/CallbackParameters.cs b/src/Flecs.NET.Codegen/Helpers/CallbackParameters.cs new file mode 100644 index 00000000..755494e9 --- /dev/null +++ b/src/Flecs.NET.Codegen/Helpers/CallbackParameters.cs @@ -0,0 +1,15 @@ +namespace Flecs.NET.Codegen.Helpers; + +public enum CallbackParameters +{ + IterField, + IterSpan, + IterPointer, + EachRef, + EachEntityRef, + EachIterRef, + EachPointer, + EachEntityPointer, + EachIterPointer, + ReadRef +} diff --git a/src/Flecs.NET.Codegen/Helpers/Generator.cs b/src/Flecs.NET.Codegen/Helpers/Generator.cs index 3414de51..388eb46b 100644 --- a/src/Flecs.NET.Codegen/Helpers/Generator.cs +++ b/src/Flecs.NET.Codegen/Helpers/Generator.cs @@ -12,111 +12,43 @@ public static class Generator #region Type Parameters - // Generates "T0, T1, T2, ..." public static readonly string[] TypeParameters = CacheJoinedStrings(Separator.Comma, i => $"T{i}"); - // Generates "T0, T1, T2, ..." - public static readonly string[] TypeParametersUnderscored = CacheJoinedStrings(Separator.Comma, i => $"T_{i}"); - - // Generates "ref T0, ref T1, ref T2, ..." public static readonly string[] RefTypeParameters = CacheJoinedStrings(Separator.Comma, i => $"ref T{i}"); - - // Generates "Field, Field, Field $"Field"); - - // Generates "Span, Span, Span $"Span"); - - // Generates "T0*, T1*, T2*, ..." public static readonly string[] PointerTypeParameters = CacheJoinedStrings(Separator.Comma, i => $"T{i}*"); - - // Generates "T0 t0, T1 t1, T2 t2, ..." - public static readonly string[] Parameters = CacheJoinedStrings(Separator.Comma, i => $"T{i} t{i}"); - - // Generates "ref T0 t0, ref T1 t1, ref T2 t2, ..." public static readonly string[] RefParameters = CacheJoinedStrings(Separator.Comma, i => $"ref T{i} t{i}"); - - // Generates "Field t0, Field t1, Field t2, ..." public static readonly string[] FieldParameters = CacheJoinedStrings(Separator.Comma, i => $"Field t{i}"); - - // Generates "Span t0, Span t1, Span t2, ..." public static readonly string[] SpanParameters = CacheJoinedStrings(Separator.Comma, i => $"Span t{i}"); - - // Generates "T0* t0, T1* t1, T2* t2, ..." public static readonly string[] PointerParameters = CacheJoinedStrings(Separator.Comma, i => $"T{i}* t{i}"); - - // Generates "ref readonly t0, ref readonly T1 t1, ref readonly T2 t2, ..." public static readonly string[] RefReadOnlyParameters = CacheJoinedStrings(Separator.Comma, i => $"ref readonly T{i} t{i}"); - // Generates "where T0 : unmanaged where T1 : unmanaged where T2 : unmanaged..." - public static readonly string[] TypeConstraints = CacheJoinedStrings(Separator.Space, i => $"where T{i} : unmanaged"); - - // Generates "where T0_ : unmanaged, T0 where T1_ : unmanaged, T1 where T2_ : unmanaged, T2..." - public static readonly string[] TypeConstraintsUnderScored = CacheJoinedStrings(Separator.Space, i => $"where T_{i} : unmanaged, T{i}"); - #endregion #region Callback Delegates public const string RunCallbackDelegate = "Ecs.RunCallback"; - public const string IterCallbackDelegate = "Ecs.IterCallback"; - - public const string EachEntityCallbackDelegate = "Ecs.EachEntityCallback"; - - public const string EachIterCallbackDelegate = "Ecs.EachIterCallback"; - - // Generates "Ecs.IterFieldCallback" public static readonly string[] IterFieldCallbackDelegate = CacheStrings(i => $"Ecs.IterFieldCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.IterSpanCallback" public static readonly string[] IterSpanCallbackDelegate = CacheStrings(i => $"Ecs.IterSpanCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.IterPointerCallback" public static readonly string[] IterPointerCallbackDelegate = CacheStrings(i => $"Ecs.IterPointerCallback<{TypeParameters[i]}>"); - // Generates "Ecs.EachRefCallback" public static readonly string[] EachRefCallbackDelegate = CacheStrings(i => $"Ecs.EachRefCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.EachEntityRefCallback" public static readonly string[] EachEntityRefCallbackDelegate = CacheStrings(i => $"Ecs.EachEntityRefCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.EachIterRefCallback" public static readonly string[] EachIterRefCallbackDelegate = CacheStrings(i => $"Ecs.EachIterRefCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.EachPointerCallback" public static readonly string[] EachPointerCallbackDelegate = CacheStrings(i => $"Ecs.EachPointerCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.EachEntityPointerCallback" public static readonly string[] EachEntityPointerCallbackDelegate = CacheStrings(i => $"Ecs.EachEntityPointerCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.EachIterPointerCallback" public static readonly string[] EachIterPointerCallbackDelegate = CacheStrings(i => $"Ecs.EachIterPointerCallback<{TypeParameters[i]}>"); - // Generates "Ecs.FindRefCallback" public static readonly string[] FindRefCallbackDelegate = CacheStrings(i => $"Ecs.FindRefCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.FindEntityRefCallback" public static readonly string[] FindEntityRefCallbackDelegate = CacheStrings(i => $"Ecs.FindEntityRefCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.FindIterRefCallback" public static readonly string[] FindIterRefCallbackDelegate = CacheStrings(i => $"Ecs.FindIterRefCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.FindPointerCallback" public static readonly string[] FindPointerCallbackDelegate = CacheStrings(i => $"Ecs.FindPointerCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.FindEntityPointerCallback" public static readonly string[] FindEntityPointerCallbackDelegate = CacheStrings(i => $"Ecs.FindEntityPointerCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.FindIterPointerCallback" public static readonly string[] FindIterPointerCallbackDelegate = CacheStrings(i => $"Ecs.FindIterPointerCallback<{TypeParameters[i]}>"); - // Generates "Ecs.ReadRefCallback" public static readonly string[] ReadRefCallbackDelegate = CacheStrings(i => $"Ecs.ReadRefCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.WriteRefCallback" public static readonly string[] WriteRefCallbackDelegate = CacheStrings(i => $"Ecs.WriteRefCallback<{TypeParameters[i]}>"); - - // Generates "Ecs.InsertRefCallback" public static readonly string[] InsertRefCallbackDelegate = CacheStrings(i => $"Ecs.InsertRefCallback<{TypeParameters[i]}>"); #endregion @@ -125,120 +57,40 @@ public static class Generator public const string RunCallbackPointer = "delegate*"; - public const string IterCallbackPointer = "delegate*"; - - public const string EachEntityCallbackPointer = "delegate*"; - - public const string EachIterCallbackPointer = "delegate*"; - - // Generates "delegate*, Field, Field, void>" public static readonly string[] IterFieldCallbackPointer = CacheStrings(i => $"delegate*"); - - // Generates "delegate*, Span, Span, void>" public static readonly string[] IterSpanCallbackPointer = CacheStrings(i => $"delegate*"); - - // Generates "delegate*" public static readonly string[] IterPointerCallbackPointer = CacheStrings(i => $"delegate*"); - // Generates "delegate*" public static readonly string[] EachRefCallbackPointer = CacheStrings(i => $"delegate*<{RefTypeParameters[i]}, void>"); - - // Generates "delegate*" public static readonly string[] EachEntityRefCallbackPointer = CacheStrings(i => $"delegate*"); - - // Generates "delegate*" public static readonly string[] EachIterRefCallbackPointer = CacheStrings(i => $"delegate*"); - - // Generates "delegate*" public static readonly string[] EachPointerCallbackPointer = CacheStrings(i => $"delegate*<{PointerTypeParameters[i]}, void>"); - - // Generates "delegate*" public static readonly string[] EachEntityPointerCallbackPointer = CacheStrings(i => $"delegate*"); - - // Generates "delegate*" public static readonly string[] EachIterPointerCallbackPointer = CacheStrings(i => $"delegate*"); - // Generates "delegate*" public static readonly string[] FindRefCallbackPointer = CacheStrings(i => $"delegate*<{RefTypeParameters[i]}, bool>"); - - // Generates "delegate*" public static readonly string[] FindEntityRefCallbackPointer = CacheStrings(i => $"delegate*"); - - // Generates "delegate*" public static readonly string[] FindIterRefCallbackPointer = CacheStrings(i => $"delegate*"); - - // Generates "delegate*" public static readonly string[] FindPointerCallbackPointer = CacheStrings(i => $"delegate*<{PointerTypeParameters[i]}, bool>"); - - // Generates "delegate*" public static readonly string[] FindEntityPointerCallbackPointer = CacheStrings(i => $"delegate*"); - - // Generates "delegate*" public static readonly string[] FindIterPointerCallbackPointer = CacheStrings(i => $"delegate*"); #endregion #region Invoker - // Generates "byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1);..." - public static readonly string[] IterPointerVariables = CacheJoinedStrings(Separator.Space, i => $"byte* pointer{i} = (byte*)it.GetPointer({i});"); - - // Generates "int step0 = it.Step(0); int step1 = it.Step(1);..." - public static readonly string[] IterStepVariables = CacheJoinedStrings(Separator.Space, i => $"int step{i} = it.Step({i});"); - - // Generates "pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]..." - public static readonly string[] IterPointerIncrements = CacheJoinedStrings(Separator.Comma, i => $"pointer{i} = &pointer{i}[step{i}]"); + public static readonly string[] FieldDataVariables = CacheJoinedStrings(Separator.Space, i => $"FieldData field{i} = it.GetFieldData({i});"); + public static readonly string[] FieldDataParameters = CacheJoinedStrings(Separator.Comma, i => $"ref FieldData field{i}"); + public static readonly string[] FieldDataRefs = CacheJoinedStrings(Separator.Comma, i => $"ref field{i}"); #endregion #region Invoker Callback Arguments - // Generates "it.Field(0), it.Field(1), it.Field(2)..." public static readonly string[] IterFieldArguments = CacheJoinedStrings(Separator.Comma, i => $"it.Field({i})"); - - // Generates "it.GetSpan(0), it.GetSpan(1), it.GetSpan(2)..." public static readonly string[] IterSpanArguments = CacheJoinedStrings(Separator.Comma, i => $"it.GetSpan({i})"); - - // Generates "it.GetPointer(0), it.GetPointer(1), it.GetPointer(2)..." public static readonly string[] IterPointerArguments = CacheJoinedStrings(Separator.Comma, i => $"it.GetPointer({i})"); - // Generates "ref Managed.GetTypeRef(&pointer0[i]), ref Managed.GetTypeRef(&pointer1[i]), ref Managed.GetTypeRef(&pointer2[i])..." - public static readonly string[] EachRefArguments = CacheJoinedStrings(Separator.Comma, i => $"ref Managed.GetTypeRef(&pointer{i}[i])"); - - // Generates "new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(&pointer0[i]), ref Managed.GetTypeRef(&pointer1[i]), ref Managed.GetTypeRef(&pointer2[i])" - public static readonly string[] EachEntityRefArguments = CacheStrings(i => $"new Entity(it.Handle->world, it.Handle->entities[i]), {EachRefArguments[i]}"); - - // Generates "it, i, ref Managed.GetTypeRef(&pointer0[i]), ref Managed.GetTypeRef(&pointer1[i]), ref Managed.GetTypeRef(&pointer2[i])" - public static readonly string[] EachIterRefArguments = CacheStrings(i => $"it, i, {EachRefArguments[i]}"); - - // Generates "&pointer0[i], &pointer1[i], &pointer2[i]..." - public static readonly string[] EachPointerArguments = CacheJoinedStrings(Separator.Comma, i => $"&pointer{i}[i]"); - - // Generates "new Entity(it.Handle->world, it.Handle->entities[i]), pointer0[i], &pointer1[i], &pointer2[i]" - public static readonly string[] EachEntityPointerArguments = CacheStrings(i => $"new Entity(it.Handle->world, it.Handle->entities[i]), {EachPointerArguments[i]}"); - - // Generates "it, i, pointer0[i], &pointer1[i], &pointer2[i]" - public static readonly string[] EachIterPointerArguments = CacheStrings(i => $"it, i, {EachPointerArguments[i]}"); - - // Generates "ref Managed.GetTypeRef(&pointer0[i * step0]), ref Managed.GetTypeRef(&pointer1[i * step1]), ref Managed.GetTypeRef(&pointer2[i * step2])..." - public static readonly string[] EachRefSteppedArguments = CacheJoinedStrings(Separator.Comma, i => $"ref Managed.GetTypeRef(pointer{i})"); - - // Generates "new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(&pointer0[i * step0]), ref Managed.GetTypeRef(&pointer1[i * step1]), ref Managed.GetTypeRef(&pointer2[i * step2])" - public static readonly string[] EachEntityRefSteppedArguments = CacheStrings(i => $"new Entity(it.Handle->world, it.Handle->entities[i]), {EachRefSteppedArguments[i]}"); - - // Generates "it, i, ref Managed.GetTypeRef(&pointer0[i * step0]), ref Managed.GetTypeRef(&pointer1[i * step1]), ref Managed.GetTypeRef(&pointer2[i * step2])" - public static readonly string[] EachIterRefSteppedArguments = CacheStrings(i => $"it, i, {EachRefSteppedArguments[i]}"); - - // Generates "&pointer0[i * step0], &pointer1[i * step1], &pointer2[i * step2]..." - public static readonly string[] EachPointerSteppedArguments = CacheJoinedStrings(Separator.Comma, i => $"(T{i}*)pointer{i}"); - - // Generates "new Entity(it.Handle->world, it.Handle->entities[i]), &pointer0[i * step0], &pointer1[i * step1], &pointer2[i * step2]..." - public static readonly string[] EachEntityPointerSteppedArguments = CacheStrings(i => $"new Entity(it.Handle->world, it.Handle->entities[i]), {EachPointerSteppedArguments[i]}"); - - // Generates "it, i, &pointer0[i * step0], &pointer1[i * step1], &pointer2[i * step2]..." - public static readonly string[] EachIterPointerSteppedArguments = CacheStrings(i => $"it, i, {EachPointerSteppedArguments[i]}"); - - // Generates "ref Managed.GetTypeRef(&pointers[0]), ref Managed.GetTypeRef(&pointers[0])" public static readonly string[] ReadRefArguments = CacheJoinedStrings(Separator.Comma, i => $"ref Managed.GetTypeRef(pointers[{i}])"); public static readonly string[] WriteRefArguments = ReadRefArguments; public static readonly string[] InsertRefArguments = ReadRefArguments; @@ -247,45 +99,38 @@ public static class Generator #region Entity Component Callbacks - // Generates "Type.Id(world), Type.Id(world), Type.Id(world)..." public static readonly string[] TypeIdList = CacheJoinedStrings(Separator.Comma, i => $"Type.Id(world)"); - // Generates "ecs_table_get_column_index(realWorld, table, ids[0]), ecs_table_get_column_index(realWorld, table, ids[1])..." public static readonly string[] ColumnList = CacheJoinedStrings(Separator.Comma, i => $"ecs_table_get_column_index(realWorld, table, ids[{i}])"); - // Generates "ulong* ids = stackalloc ulong[] { Type.Id(world), Type.Id(world) };" public static readonly string[] IdsArray = CacheStrings(i => $"ulong* ids = stackalloc ulong[] {{ {TypeIdList[i]} }};"); - // Generates "int* columns = stackalloc int[] { ecs_table_get_column_index(realWorld, table, ids[0]), ecs_table_get_column_index(realWorld, table, ids[1]) };" public static readonly string[] ColumnsArray = CacheStrings(i => $"int* columns = stackalloc int[] {{ {ColumnList[i]} }};"); - // Generates "ptrs[0] = ecs_ensure_id(world, e, Type.Id(world)); ptrs[1] = ecs_ensure_id(world, e, Type.Id(world));" public static readonly string[] EnsurePointers = CacheJoinedStrings(Separator.Space, i => $"ptrs[{i}] = ecs_ensure_id(world, e, Type.Id(world));"); - // Generates "ecs_modified_id(world, id, ids[0]); ecs_modified_id(world, id, ids[1]);..." public static readonly string[] ModifiedChain = CacheJoinedStrings(Separator.Space, i => $"ecs_modified_id(world, entity, ids[{i}]);"); #endregion #region Type Helpers - // Generates "(Type.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0)..." public static readonly string[] Tags = CacheJoinedStrings(Separator.BitwiseOr, i => $"(Type.IsTag ? 1 << {i} : 0)"); - // Generates "(RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0)..." public static readonly string[] ReferenceTypes = CacheJoinedStrings(Separator.BitwiseOr, i => $"(RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << {i} : 0)"); - // Generates "Type.FullName, Type.Fullname..." public static readonly string[] TypeFullNames = CacheJoinedStrings(Separator.Comma, i => $"Type.FullName"); + public static readonly string[] SparseBitField = CacheJoinedStrings(Separator.BitwiseOr, i => $"(ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << {i} : 0)"); + + public static readonly string[] ContainsReferenceTypes = CacheJoinedStrings(Separator.Or, i => $"RuntimeHelpers.IsReferenceOrContainsReferences()"); + #endregion #region Misc - // Generates ".With.With().With()..." public static readonly string[] WithChain = CacheJoinedStrings(Separator.None, i => $".With()"); - // Generates "The T0 component type. The T1 component type. The T2 component type...." public static readonly string[] XmlTypeParameters = CacheJoinedStrings(Separator.Space, i => $"The T{i} component type."); #endregion @@ -547,38 +392,115 @@ Callback.FindEntityPointerCallbackPointer or }; } - public static string GetCallbackArguments(int i, Callback callback) + public static bool GetCallbackIsIter(Callback callback) { return callback switch { - Callback.IterFieldCallbackDelegate or Callback.IterFieldCallbackPointer => IterFieldArguments[i], - Callback.IterSpanCallbackDelegate or Callback.IterSpanCallbackPointer => IterSpanArguments[i], - Callback.IterPointerCallbackDelegate or Callback.IterPointerCallbackPointer => IterPointerArguments[i], - Callback.EachRefCallbackDelegate or Callback.EachRefCallbackPointer or Callback.FindRefCallbackDelegate or Callback.FindRefCallbackPointer => EachRefArguments[i], - Callback.EachEntityRefCallbackDelegate or Callback.EachEntityRefCallbackPointer or Callback.FindEntityRefCallbackDelegate or Callback.FindEntityRefCallbackPointer => EachEntityRefArguments[i], - Callback.EachIterRefCallbackDelegate or Callback.EachIterRefCallbackPointer or Callback.FindIterRefCallbackDelegate or Callback.FindIterRefCallbackPointer => EachIterRefArguments[i], - Callback.EachPointerCallbackDelegate or Callback.EachPointerCallbackPointer or Callback.FindPointerCallbackDelegate or Callback.FindPointerCallbackPointer => EachPointerArguments[i], - Callback.EachEntityPointerCallbackDelegate or Callback.EachEntityPointerCallbackPointer or Callback.FindEntityPointerCallbackDelegate or Callback.FindEntityPointerCallbackPointer => EachEntityPointerArguments[i], - Callback.EachIterPointerCallbackDelegate or Callback.EachIterPointerCallbackPointer or Callback.FindIterPointerCallbackDelegate or Callback.FindIterPointerCallbackPointer => EachIterPointerArguments[i], - Callback.ReadRefCallbackDelegate or Callback.WriteRefCallbackDelegate or Callback.InsertRefCallbackDelegate => ReadRefArguments[i], - _ => throw new ArgumentOutOfRangeException(nameof(callback), callback, null) + Callback.IterFieldCallbackDelegate or + Callback.IterFieldCallbackPointer or + Callback.IterSpanCallbackDelegate or + Callback.IterSpanCallbackPointer or + Callback.IterPointerCallbackDelegate or + Callback.IterPointerCallbackPointer => true, + _ => false }; } - public static string GetCallbackSteppedArguments(int i, Callback callback) + public static CallbackParameters GetCallbackParameters(Callback callback) { return callback switch { - Callback.EachRefCallbackDelegate or Callback.EachRefCallbackPointer or Callback.FindRefCallbackDelegate or Callback.FindRefCallbackPointer => EachRefSteppedArguments[i], - Callback.EachEntityRefCallbackDelegate or Callback.EachEntityRefCallbackPointer or Callback.FindEntityRefCallbackDelegate or Callback.FindEntityRefCallbackPointer => EachEntityRefSteppedArguments[i], - Callback.EachIterRefCallbackDelegate or Callback.EachIterRefCallbackPointer or Callback.FindIterRefCallbackDelegate or Callback.FindIterRefCallbackPointer => EachIterRefSteppedArguments[i], - Callback.EachPointerCallbackDelegate or Callback.EachPointerCallbackPointer or Callback.FindPointerCallbackDelegate or Callback.FindPointerCallbackPointer => EachPointerSteppedArguments[i], - Callback.EachEntityPointerCallbackDelegate or Callback.EachEntityPointerCallbackPointer or Callback.FindEntityPointerCallbackDelegate or Callback.FindEntityPointerCallbackPointer => EachEntityPointerSteppedArguments[i], - Callback.EachIterPointerCallbackDelegate or Callback.EachIterPointerCallbackPointer or Callback.FindIterPointerCallbackDelegate or Callback.FindIterPointerCallbackPointer => EachIterPointerSteppedArguments[i], + Callback.IterFieldCallbackDelegate or + Callback.IterFieldCallbackPointer => CallbackParameters.IterField, + + Callback.IterSpanCallbackDelegate or + Callback.IterSpanCallbackPointer => CallbackParameters.IterSpan, + + Callback.IterPointerCallbackDelegate or + Callback.IterPointerCallbackPointer => CallbackParameters.IterPointer, + + Callback.EachRefCallbackDelegate or + Callback.EachRefCallbackPointer or + Callback.FindRefCallbackDelegate or + Callback.FindRefCallbackPointer => CallbackParameters.EachRef, + + Callback.EachEntityRefCallbackDelegate or + Callback.EachEntityRefCallbackPointer or + Callback.FindEntityRefCallbackDelegate or + Callback.FindEntityRefCallbackPointer => CallbackParameters.EachEntityRef, + + Callback.EachIterRefCallbackDelegate or + Callback.EachIterRefCallbackPointer or + Callback.FindIterRefCallbackDelegate or + Callback.FindIterRefCallbackPointer => CallbackParameters.EachIterRef, + + Callback.EachPointerCallbackDelegate or + Callback.EachPointerCallbackPointer or + Callback.FindPointerCallbackDelegate or + Callback.FindPointerCallbackPointer => CallbackParameters.EachPointer, + + Callback.EachEntityPointerCallbackDelegate or + Callback.EachEntityPointerCallbackPointer or + Callback.FindEntityPointerCallbackDelegate or + Callback.FindEntityPointerCallbackPointer => CallbackParameters.EachEntityPointer, + + Callback.EachIterPointerCallbackDelegate or + Callback.EachIterPointerCallbackPointer or + Callback.FindIterPointerCallbackDelegate or + Callback.FindIterPointerCallbackPointer => CallbackParameters.EachIterPointer, + + Callback.ReadRefCallbackDelegate or + Callback.WriteRefCallbackDelegate or + Callback.InsertRefCallbackDelegate => CallbackParameters.ReadRef, + _ => throw new ArgumentOutOfRangeException(nameof(callback), callback, null) }; } + public static string GetCallbackArguments(Callback callback, int i) + { + return GetCallbackParameters(callback) switch + { + CallbackParameters.IterField => IterFieldArguments[i], + CallbackParameters.IterSpan => IterSpanArguments[i], + CallbackParameters.IterPointer => IterPointerArguments[i], + CallbackParameters.ReadRef => ReadRefArguments[i], + _ => throw new ArgumentOutOfRangeException(nameof(callback)) + }; + } + + public static string GetCallbackArguments(Callback parameters, IterationTechnique iterationTechnique, int i) + { + return GetCallbackParameters(parameters) switch + { + CallbackParameters.EachRef => $"{GetEachRefArguments(iterationTechnique, i)}", + CallbackParameters.EachPointer => $"{GetEachPointerArguments(iterationTechnique, i)}", + CallbackParameters.EachEntityRef => $"new Entity(it.Handle->world, it.Handle->entities[i]), {GetEachRefArguments(iterationTechnique, i)}", + CallbackParameters.EachEntityPointer => $"new Entity(it.Handle->world, it.Handle->entities[i]), {GetEachPointerArguments(iterationTechnique, i)}", + CallbackParameters.EachIterRef => $"it, i, {GetEachRefArguments(iterationTechnique, i)}", + CallbackParameters.EachIterPointer => $"it, i, {GetEachPointerArguments(iterationTechnique, i)}", + _ => throw new ArgumentOutOfRangeException(nameof(parameters), parameters, null) + }; + } + + public static readonly string[][] EachPointerArguments = typeof(IterationTechnique).GetEnumNames() + .Select((str) => CacheJoinedStrings(Separator.Comma, i => $"field{i}.Pointer{str}(i)")) + .ToArray(); + + public static readonly string[][] EachRefArguments = typeof(IterationTechnique).GetEnumNames() + .Select((str) => CacheJoinedStrings(Separator.Comma, i => $"ref field{i}.Ref{str}(i)")) + .ToArray(); + + public static string GetEachPointerArguments(IterationTechnique type, int i) + { + return EachPointerArguments[(int)type][i]; + } + + public static string GetEachRefArguments(IterationTechnique type, int i) + { + return EachRefArguments[(int)type][i]; + } + public static string GetCallbackCountVariable(Callback callback) { return callback switch diff --git a/src/Flecs.NET.Codegen/Helpers/IterationTechnique.cs b/src/Flecs.NET.Codegen/Helpers/IterationTechnique.cs new file mode 100644 index 00000000..b6a53024 --- /dev/null +++ b/src/Flecs.NET.Codegen/Helpers/IterationTechnique.cs @@ -0,0 +1,14 @@ +namespace Flecs.NET.Codegen.Helpers; + +public enum IterationTechnique +{ + Unmanaged, + SharedUnmanaged, + SparseUnmanaged, + SparseSharedUnmanaged, + + Managed, + SharedManaged, + SparseManaged, + SparseSharedManaged +} diff --git a/src/Flecs.NET.Codegen/Helpers/Separator.cs b/src/Flecs.NET.Codegen/Helpers/Separator.cs index aecaee5f..55af70db 100644 --- a/src/Flecs.NET.Codegen/Helpers/Separator.cs +++ b/src/Flecs.NET.Codegen/Helpers/Separator.cs @@ -7,6 +7,7 @@ public static class Separator public const string Space = " "; public const string NewLine = "\n"; public const string DoubleNewLine = "\n\n"; + public const string And = " && "; public const string Or = " || "; public const string BitwiseOr = " | "; } diff --git a/src/Flecs.NET.Examples/Observers/YieldExisting.cs b/src/Flecs.NET.Examples/Observers/YieldExisting.cs index 0a849cb0..ff2e274a 100644 --- a/src/Flecs.NET.Examples/Observers/YieldExisting.cs +++ b/src/Flecs.NET.Examples/Observers/YieldExisting.cs @@ -1,9 +1,6 @@ // Observers can enable a "YieldExisting" feature that upon creation of the // observer produces events for all entities that match the observer query. The // feature is only implemented for the builtin EcsOnAdd and EcsOnSet events. -// -// Custom events can also implement behavior for YieldExisting by adding the -// Iterable component to the event (see EcsIterable for more details). using Flecs.NET.Core; diff --git a/src/Flecs.NET.Native/Flecs.NET.Native.csproj b/src/Flecs.NET.Native/Flecs.NET.Native.csproj index 5346c0cb..7668c50d 100644 --- a/src/Flecs.NET.Native/Flecs.NET.Native.csproj +++ b/src/Flecs.NET.Native/Flecs.NET.Native.csproj @@ -10,7 +10,7 @@ true false - 4.0.0 + 4.0.1 Flecs.NET.Native.Debug Flecs.NET.Native.Release BeanCheeseBurrito diff --git a/src/Flecs.NET.Native/build.zig b/src/Flecs.NET.Native/build.zig index f109527a..97be1b05 100644 --- a/src/Flecs.NET.Native/build.zig +++ b/src/Flecs.NET.Native/build.zig @@ -20,7 +20,7 @@ pub fn compileFlecs(options: anytype, b: *Build, lib_type: LibType) void { }; lib.linkLibC(); - lib.addCSourceFile(.{ .file = b.path("../../submodules/flecs/flecs.c"), .flags = &.{} }); + lib.addCSourceFile(.{ .file = b.path("../../submodules/flecs/flecs.c"), .flags = &.{"-fno-sanitize=undefined"} }); lib.defineCMacro(if (options.optimize == .Debug) "FLECS_DEBUG" else "FLECS_NDEBUG", null); if (options.soft_assert) { diff --git a/src/Flecs.NET.Tests/CSharp/Core/QueryTests.cs b/src/Flecs.NET.Tests/CSharp/Core/QueryTests.cs index bcffc7e6..0d619519 100644 --- a/src/Flecs.NET.Tests/CSharp/Core/QueryTests.cs +++ b/src/Flecs.NET.Tests/CSharp/Core/QueryTests.cs @@ -798,7 +798,7 @@ private void EachManagedClass() Assert.True(query.IsTrue()); Assert.Equal(5, query.Count()); - query.Each(static (Iter _, int i, ref ManagedClass component) => + query.Each(static (Iter _, int _, ref ManagedClass component) => { Assert.Equal(10, component.Value); }); @@ -816,10 +816,178 @@ private void EachManagedStruct() Assert.True(query.IsTrue()); Assert.Equal(5, query.Count()); - query.Each(static (Iter it, int i, ref ManagedStruct component) => + query.Each(static (Iter _, int _, ref ManagedStruct component) => { Assert.Equal(10, component.Value); }); } + + [Fact] + private void EachSharedUnmanaged() + { + using World world = World.Create(); + + world.Component().Entity.Add(Ecs.OnInstantiate, Ecs.Inherit); + + using Query query = world.Query(); + + Entity prefab = world.Prefab() + .Set(new UnmanagedComponent(10)) + .Set(new SharedComponent(20)); + + for (int i = 0; i < 5; i++) + world.Entity().IsA(prefab); + + Assert.True(query.IsTrue()); + Assert.Equal(5, query.Count()); + + query.Each(static (Iter it, int _, ref UnmanagedComponent c1, ref SharedComponent c2) => + { + Assert.Equal(IterationTechnique.Shared, it.GetIterationTechnique(2)); + Assert.Equal(10, c1.Value); + Assert.Equal(20, c2.Value); + }); + } + + [Fact] + private void EachSharedManaged() + { + using World world = World.Create(); + + world.Component().Entity.Add(Ecs.OnInstantiate, Ecs.Inherit); + + using Query query = world.Query(); + + Entity prefab = world.Prefab() + .Set(new ManagedComponent(10)) + .Set(new SharedComponent(20)); + + for (int i = 0; i < 5; i++) + world.Entity().IsA(prefab); + + Assert.True(query.IsTrue()); + Assert.Equal(5, query.Count()); + + query.Each(static (Iter it, int _, ref ManagedComponent c1, ref SharedComponent c2) => + { + Assert.Equal(IterationTechnique.Shared, it.GetIterationTechnique(2)); + Assert.Equal(10, c1.Value); + Assert.Equal(20, c2.Value); + }); + } + + [Fact] + private void EachSparseUnmanaged() + { + using World world = World.Create(); + + world.Component().Entity.Add(Ecs.Sparse); + + using Query query = world.Query(); + + Entity prefab = world.Prefab() + .Set(new UnmanagedComponent(10)) + .Set(new SparseComponent(20)); + + for (int i = 0; i < 5; i++) + world.Entity().IsA(prefab); + + Assert.True(query.IsTrue()); + Assert.Equal(5, query.Count()); + + query.Each(static (Iter it, int _, ref UnmanagedComponent c1, ref SparseComponent c2) => + { + Assert.Equal(IterationTechnique.Sparse, it.GetIterationTechnique(2)); + Assert.Equal(10, c1.Value); + Assert.Equal(20, c2.Value); + }); + } + + [Fact] + private void EachSparseManaged() + { + using World world = World.Create(); + + world.Component().Entity.Add(Ecs.Sparse); + + using Query query = world.Query(); + + Entity prefab = world.Prefab() + .Set(new ManagedComponent(10)) + .Set(new SparseComponent(20)); + + for (int i = 0; i < 5; i++) + world.Entity().IsA(prefab); + + Assert.True(query.IsTrue()); + Assert.Equal(5, query.Count()); + + query.Each(static (Iter it, int _, ref ManagedComponent c1, ref SparseComponent c2) => + { + Assert.Equal(IterationTechnique.Sparse, it.GetIterationTechnique(2)); + Assert.Equal(10, c1.Value); + Assert.Equal(20, c2.Value); + }); + } + + [Fact] + private void EachSparseSharedUnmanaged() + { + using World world = World.Create(); + + world.Component().Entity.Add(Ecs.Sparse); + world.Component().Entity.Add(Ecs.OnInstantiate, Ecs.Inherit); + + using Query query = world.Query(); + + Entity prefab = world.Prefab() + .Set(new UnmanagedComponent(10)) + .Set(new SparseComponent(20)) + .Set(new SharedComponent(30)); + + for (int i = 0; i < 5; i++) + world.Entity().IsA(prefab); + + Assert.True(query.IsTrue()); + Assert.Equal(5, query.Count()); + + query.Each(static (Iter it, int _, ref UnmanagedComponent c1, ref SparseComponent c2, ref SharedComponent c3) => + { + Assert.Equal(IterationTechnique.Sparse | IterationTechnique.Shared, it.GetIterationTechnique(3)); + Assert.Equal(10, c1.Value); + Assert.Equal(20, c2.Value); + Assert.Equal(30, c3.Value); + }); + } + + [Fact] + private void EachSparseSharedManaged() + { + using World world = World.Create(); + + world.Component().Entity.Add(Ecs.Sparse); + world.Component().Entity.Add(Ecs.OnInstantiate, Ecs.Inherit); + + using Query query = world.Query(); + + Entity prefab = world.Prefab() + .Set(new ManagedComponent(10)) + .Set(new SparseComponent(20)) + .Set(new SharedComponent(30)); + + for (int i = 0; i < 5; i++) + world.Entity().IsA(prefab); + + Assert.True(query.IsTrue()); + Assert.Equal(5, query.Count()); + + query.Each(static (Iter it, int _, ref ManagedComponent c1, ref SparseComponent c2, ref SharedComponent c3) => + { + Assert.Equal(IterationTechnique.Sparse | IterationTechnique.Shared, it.GetIterationTechnique(3)); + Assert.Equal(10, c1.Value); + Assert.Equal(20, c2.Value); + Assert.Equal(30, c3.Value); + }); + } } } diff --git a/src/Flecs.NET.Tests/CSharp/Core/TypeRegistrationTests.cs b/src/Flecs.NET.Tests/CSharp/Core/TypeRegistrationTests.cs index 2fb9c493..13385080 100644 --- a/src/Flecs.NET.Tests/CSharp/Core/TypeRegistrationTests.cs +++ b/src/Flecs.NET.Tests/CSharp/Core/TypeRegistrationTests.cs @@ -85,7 +85,7 @@ private void TypeEnum(bool scoped) Assert.True(green.Has(EcsConstant, Ecs.Wildcard)); Assert.True(blue.Has(EcsConstant, Ecs.Wildcard)); } - + [Fact] private void ComponentStructReflection() { @@ -97,14 +97,14 @@ private void ComponentStructReflection() Assert.True(world.Entity(posComponent).Has()); Assert.Equal(typeof(Position), world.Entity(posComponent).Get()); } - + [Fact] private void ComponentClassReflection() { using World world = World.Create(); world.Component(); - Entity entity = world.Entity("Test").Set(new ManagedComponent()); + Entity entity = world.Entity("Test").Set(new ManagedComponent(1)); Id comp = entity.Table().Type().Get(0); Assert.True(world.Entity(comp).Has()); Assert.Equal(typeof(ManagedComponent), world.Entity(comp).Get()); diff --git a/src/Flecs.NET.Tests/Cpp/ObserverTests.cs b/src/Flecs.NET.Tests/Cpp/ObserverTests.cs index 304ee7d4..930d1ac4 100644 --- a/src/Flecs.NET.Tests/Cpp/ObserverTests.cs +++ b/src/Flecs.NET.Tests/Cpp/ObserverTests.cs @@ -870,6 +870,29 @@ private void OnSetWithDeferSet() Assert.Equal(1, count); } + [Fact] + private void OnSetWithSetSetSparse() + { + using World world = World.Create(); + + world.Component().Entity.Add(Ecs.Sparse); + + int count = 0; + + world.Observer() + .Event(Ecs.OnSet) + .Each((Entity _, ref Position _) => + { + count++; + }); + + Entity e = world.Entity(); + Assert.Equal(0, count); + + e.Set(new Position(10, 20)); + Assert.Equal(1, count); + } + [Fact] private void OnAddSingleton() { diff --git a/src/Flecs.NET.Tests/Cpp/QueryTests.cs b/src/Flecs.NET.Tests/Cpp/QueryTests.cs index 083e851b..458fcd72 100644 --- a/src/Flecs.NET.Tests/Cpp/QueryTests.cs +++ b/src/Flecs.NET.Tests/Cpp/QueryTests.cs @@ -566,7 +566,7 @@ private void FindWithEntity() } [Fact] - private void Action() + private void Run() { using World world = World.Create(); @@ -600,7 +600,7 @@ private void Action() } [Fact] - private void ActionConst() + private void RunConst() { using World world = World.Create(); @@ -634,7 +634,7 @@ private void ActionConst() } [Fact] - private void ActionShared() + private void RunShared() { using World world = World.Create(); @@ -688,7 +688,7 @@ private void ActionShared() } [Fact] - private void ActionOptional() + private void RunOptional() { using World world = World.Create(); @@ -757,6 +757,40 @@ private void ActionOptional() Assert.Equal(81, p->Y); } + [Fact] + private void RunSparse() + { + using World world = World.Create(); + + world.Component().Entity.Add(Ecs.Sparse); + world.Component(); + + Entity entity = world.Entity() + .Set(new Position(10, 20)) + .Set(new Velocity(1, 2)); + + Query q = world.Query(); + + q.Run((Iter it) => + { + while (it.Next()) + { + Field v = it.Field(1); + + foreach (int i in it) + { + ref Position p = ref it.FieldAt(0, i); + p.X += v[i].X; + p.Y += v[i].Y; + } + } + }); + + Position* p = entity.GetPtr(); + Assert.Equal(11, p->X); + Assert.Equal(22, p->Y); + } + [Fact] private void Each() { @@ -912,6 +946,31 @@ private void EachOptional() Assert.Equal(81, p->Y); } + [Fact] + private void EachSparse() + { + using World world = World.Create(); + + world.Component().Entity.Add(Ecs.Sparse); + world.Component(); + + Entity entity = world.Entity() + .Set(new Position(10, 20)) + .Set(new Velocity(1, 2)); + + Query q = world.Query(); + + q.Each((ref Position p, ref Velocity v) => + { + p.X += v.X; + p.Y += v.Y; + }); + + Position* p = entity.GetPtr(); + Assert.Equal(11, p->X); + Assert.Equal(22, p->Y); + } + [Fact] private void Signature() { diff --git a/src/Flecs.NET.Tests/Helpers.cs b/src/Flecs.NET.Tests/Helpers.cs index 2b5e81dd..71741cd3 100644 --- a/src/Flecs.NET.Tests/Helpers.cs +++ b/src/Flecs.NET.Tests/Helpers.cs @@ -29,6 +29,11 @@ public record struct Other(int Value); public record struct Singleton(int Value); public record struct PositionInitialized(float X, float Y); +public record ManagedComponent(int Value); +public record struct UnmanagedComponent(int Value); +public record struct SharedComponent(int Value); +public record struct SparseComponent(int Value); + public record struct ManagedStruct(int Value) { public object Dummy = null!; @@ -40,13 +45,6 @@ public class ManagedClass(int value) public object Dummy = null!; } -public class ManagedComponent -{ - public string Value = null!; - public ManagedComponent Nested = null!; -} - - public struct Base; public struct Prefab; diff --git a/src/Flecs.NET/Core/BindingContext/Functions.cs b/src/Flecs.NET/Core/BindingContext/Functions.cs index 10c5a5c0..37e63c7a 100644 --- a/src/Flecs.NET/Core/BindingContext/Functions.cs +++ b/src/Flecs.NET/Core/BindingContext/Functions.cs @@ -459,522 +459,325 @@ internal static void ManagedCopyCallbackPointer(GCHandle* dst, GCHandle* src, in internal static void OnAddIterFieldCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.IterFieldCallback callback = (Ecs.IterFieldCallback)context->OnAdd.GcHandle.Target!; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Field(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (Ecs.IterFieldCallback)context->OnAdd.GcHandle.Target!); } internal static void OnAddIterFieldCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate*, void> callback = (delegate*, void>)context->OnAdd.Pointer; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Field(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (delegate*, void>)context->OnAdd.Pointer); } internal static void OnAddIterSpanCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.IterSpanCallback callback = (Ecs.IterSpanCallback)context->OnAdd.GcHandle.Target!; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Span(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (Ecs.IterSpanCallback)context->OnAdd.GcHandle.Target!); } internal static void OnAddIterSpanCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate*, void> callback = (delegate*, void>)context->OnAdd.Pointer; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Span(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (delegate*, void>)context->OnAdd.Pointer); } internal static void OnAddIterPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.IterPointerCallback callback = (Ecs.IterPointerCallback)context->OnAdd.GcHandle.Target!; - - for (int i = 0; i < iter->count; i++) - callback(iter, (T0*)iter->ptrs[0]); + Invoker.Iter(iter, (Ecs.IterPointerCallback)context->OnAdd.GcHandle.Target!); } internal static void OnAddIterPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnAdd.Pointer; - - for (int i = 0; i < iter->count; i++) - callback(iter, (T0*)iter->ptrs[0]); + Invoker.Iter(iter, (delegate*)context->OnAdd.Pointer); } internal static void OnAddEachRefCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachRefCallback callback = (Ecs.EachRefCallback)context->OnAdd.GcHandle.Target!; + Invoker.Each(iter, (Ecs.EachRefCallback)context->OnAdd.GcHandle.Target!); - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(ref Managed.GetTypeRef(&pointer[i])); } internal static void OnAddEachRefCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnAdd.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (delegate*)context->OnAdd.Pointer); } internal static void OnAddEachEntityRefCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachEntityRefCallback callback = (Ecs.EachEntityRefCallback)context->OnAdd.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (Ecs.EachEntityRefCallback)context->OnAdd.GcHandle.Target!); } internal static void OnAddEachEntityRefCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnAdd.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (delegate*)context->OnAdd.Pointer); } internal static void OnAddEachIterRefCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachIterRefCallback callback = (Ecs.EachIterRefCallback)context->OnAdd.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (Ecs.EachIterRefCallback)context->OnAdd.GcHandle.Target!); } internal static void OnAddEachIterRefCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnAdd.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (delegate*)context->OnAdd.Pointer); } internal static void OnAddEachPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachPointerCallback callback = (Ecs.EachPointerCallback)context->OnAdd.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(&pointer[i]); + Invoker.Each(iter, (Ecs.EachPointerCallback)context->OnAdd.GcHandle.Target!); } internal static void OnAddEachPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnAdd.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(&pointer[i]); + Invoker.Each(iter, (delegate*)context->OnAdd.Pointer); } internal static void OnAddEachEntityPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachEntityPointerCallback callback = (Ecs.EachEntityPointerCallback)context->OnAdd.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), &pointer[i]); + Invoker.Each(iter, (Ecs.EachEntityPointerCallback)context->OnAdd.GcHandle.Target!); } internal static void OnAddEachEntityPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnAdd.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), &pointer[i]); + Invoker.Each(iter, (delegate*)context->OnAdd.Pointer); } internal static void OnAddEachIterPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachIterPointerCallback callback = (Ecs.EachIterPointerCallback)context->OnAdd.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, &pointer[i]); + Invoker.Each(iter, (Ecs.EachIterPointerCallback)context->OnAdd.GcHandle.Target!); } internal static void OnAddEachIterPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnAdd.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, &pointer[i]); + Invoker.Each(iter, (delegate*)context->OnAdd.Pointer); } internal static void OnSetIterFieldCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.IterFieldCallback callback = (Ecs.IterFieldCallback)context->OnSet.GcHandle.Target!; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Field(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (Ecs.IterFieldCallback)context->OnSet.GcHandle.Target!); } internal static void OnSetIterFieldCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate*, void> callback = (delegate*, void>)context->OnSet.Pointer; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Field(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (delegate*, void>)context->OnSet.Pointer); } internal static void OnSetIterSpanCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.IterSpanCallback callback = (Ecs.IterSpanCallback)context->OnSet.GcHandle.Target!; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Span(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (Ecs.IterSpanCallback)context->OnSet.GcHandle.Target!); } internal static void OnSetIterSpanCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate*, void> callback = (delegate*, void>)context->OnSet.Pointer; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Span(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (delegate*, void>)context->OnSet.Pointer); } internal static void OnSetIterPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.IterPointerCallback callback = (Ecs.IterPointerCallback)context->OnSet.GcHandle.Target!; - - for (int i = 0; i < iter->count; i++) - callback(iter, (T0*)iter->ptrs[0]); + Invoker.Iter(iter, (Ecs.IterPointerCallback)context->OnSet.GcHandle.Target!); } internal static void OnSetIterPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnSet.Pointer; - - for (int i = 0; i < iter->count; i++) - callback(iter, (T0*)iter->ptrs[0]); + Invoker.Iter(iter, (delegate*)context->OnSet.Pointer); } internal static void OnSetEachRefCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachRefCallback callback = (Ecs.EachRefCallback)context->OnSet.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (Ecs.EachRefCallback)context->OnSet.GcHandle.Target!); } internal static void OnSetEachRefCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnSet.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (delegate*)context->OnSet.Pointer); } internal static void OnSetEachEntityRefCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachEntityRefCallback callback = (Ecs.EachEntityRefCallback)context->OnSet.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (Ecs.EachEntityRefCallback)context->OnSet.GcHandle.Target!); } internal static void OnSetEachEntityRefCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnSet.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (delegate*)context->OnSet.Pointer); } internal static void OnSetEachIterRefCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachIterRefCallback callback = (Ecs.EachIterRefCallback)context->OnSet.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (Ecs.EachIterRefCallback)context->OnSet.GcHandle.Target!); } internal static void OnSetEachIterRefCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnSet.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (delegate*)context->OnSet.Pointer); } internal static void OnSetEachPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachPointerCallback callback = (Ecs.EachPointerCallback)context->OnSet.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(&pointer[i]); + Invoker.Each(iter, (Ecs.EachPointerCallback)context->OnSet.GcHandle.Target!); } internal static void OnSetEachPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnSet.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(&pointer[i]); + Invoker.Each(iter, (delegate*)context->OnSet.Pointer); } internal static void OnSetEachEntityPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachEntityPointerCallback callback = (Ecs.EachEntityPointerCallback)context->OnSet.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), &pointer[i]); + Invoker.Each(iter, (Ecs.EachEntityPointerCallback)context->OnSet.GcHandle.Target!); } internal static void OnSetEachEntityPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnSet.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), &pointer[i]); + Invoker.Each(iter, (delegate*)context->OnSet.Pointer); } internal static void OnSetEachIterPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachIterPointerCallback callback = (Ecs.EachIterPointerCallback)context->OnSet.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, &pointer[i]); + Invoker.Each(iter, (Ecs.EachIterPointerCallback)context->OnSet.GcHandle.Target!); } internal static void OnSetEachIterPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnSet.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, &pointer[i]); + Invoker.Each(iter, (delegate*)context->OnSet.Pointer); } internal static void OnRemoveIterFieldCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.IterFieldCallback callback = (Ecs.IterFieldCallback)context->OnRemove.GcHandle.Target!; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Field(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (Ecs.IterFieldCallback)context->OnRemove.GcHandle.Target!); } internal static void OnRemoveIterFieldCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate*, void> callback = (delegate*, void>)context->OnRemove.Pointer; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Field(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (delegate*, void>)context->OnRemove.Pointer); } internal static void OnRemoveIterSpanCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.IterSpanCallback callback = (Ecs.IterSpanCallback)context->OnRemove.GcHandle.Target!; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Span(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (Ecs.IterSpanCallback)context->OnRemove.GcHandle.Target!); } internal static void OnRemoveIterSpanCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate*, void> callback = (delegate*, void>)context->OnRemove.Pointer; - - for (int i = 0; i < iter->count; i++) - callback(iter, new Span(iter->ptrs[0], iter->count)); + Invoker.Iter(iter, (delegate*, void>)context->OnRemove.Pointer); } internal static void OnRemoveIterPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.IterPointerCallback callback = (Ecs.IterPointerCallback)context->OnRemove.GcHandle.Target!; - - for (int i = 0; i < iter->count; i++) - callback(iter, (T0*)iter->ptrs[0]); + Invoker.Iter(iter, (Ecs.IterPointerCallback)context->OnRemove.GcHandle.Target!); } internal static void OnRemoveIterPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnRemove.Pointer; - - for (int i = 0; i < iter->count; i++) - callback(iter, (T0*)iter->ptrs[0]); + Invoker.Iter(iter, (delegate*)context->OnRemove.Pointer); } internal static void OnRemoveEachRefCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachRefCallback callback = (Ecs.EachRefCallback)context->OnRemove.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (Ecs.EachRefCallback)context->OnRemove.GcHandle.Target!); } internal static void OnRemoveEachRefCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnRemove.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (delegate*)context->OnRemove.Pointer); } internal static void OnRemoveEachEntityRefCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachEntityRefCallback callback = (Ecs.EachEntityRefCallback)context->OnRemove.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (Ecs.EachEntityRefCallback)context->OnRemove.GcHandle.Target!); } internal static void OnRemoveEachEntityRefCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnRemove.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (delegate*)context->OnRemove.Pointer); } internal static void OnRemoveEachIterRefCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachIterRefCallback callback = (Ecs.EachIterRefCallback)context->OnRemove.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (Ecs.EachIterRefCallback)context->OnRemove.GcHandle.Target!); } internal static void OnRemoveEachIterRefCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnRemove.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, ref Managed.GetTypeRef(&pointer[i])); + Invoker.Each(iter, (delegate*)context->OnRemove.Pointer); } internal static void OnRemoveEachPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachPointerCallback callback = (Ecs.EachPointerCallback)context->OnRemove.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(&pointer[i]); + Invoker.Each(iter, (Ecs.EachPointerCallback)context->OnRemove.GcHandle.Target!); } internal static void OnRemoveEachPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnRemove.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(&pointer[i]); + Invoker.Each(iter, (delegate*)context->OnRemove.Pointer); } internal static void OnRemoveEachEntityPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachEntityPointerCallback callback = (Ecs.EachEntityPointerCallback)context->OnRemove.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), &pointer[i]); + Invoker.Each(iter, (Ecs.EachEntityPointerCallback)context->OnRemove.GcHandle.Target!); } internal static void OnRemoveEachEntityPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnRemove.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Entity(iter->world, iter->entities[i]), &pointer[i]); + Invoker.Each(iter, (delegate*)context->OnRemove.Pointer); } internal static void OnRemoveEachIterPointerCallbackDelegate(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - Ecs.EachIterPointerCallback callback = (Ecs.EachIterPointerCallback)context->OnRemove.GcHandle.Target!; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, &pointer[i]); + Invoker.Each(iter, (Ecs.EachIterPointerCallback)context->OnRemove.GcHandle.Target!); } internal static void OnRemoveEachIterPointerCallbackPointer(ecs_iter_t* iter) { TypeHooksContext* context = (TypeHooksContext*)iter->callback_ctx; - delegate* callback = (delegate*)context->OnRemove.Pointer; - - T0* pointer = (T0*)iter->ptrs[0]; - for (int i = 0; i < iter->count; i++) - callback(new Iter(iter), i, &pointer[i]); + Invoker.Each(iter, (delegate*)context->OnRemove.Pointer); } } diff --git a/src/Flecs.NET/Core/Ecs/Aliases.cs b/src/Flecs.NET/Core/Ecs/Aliases.cs index 8af26c44..ceebe6a4 100644 --- a/src/Flecs.NET/Core/Ecs/Aliases.cs +++ b/src/Flecs.NET/Core/Ecs/Aliases.cs @@ -644,11 +644,6 @@ public static partial class Ecs /// public const uint QueryMatchEmptyTables = EcsQueryMatchEmptyTables; - /// - /// Query won't provide component data. - /// - public const uint QueryNoData = EcsQueryNoData; - /// /// Query may have unresolved entity identifiers. /// diff --git a/src/Flecs.NET/Core/Ecs/Macros.cs b/src/Flecs.NET/Core/Ecs/Macros.cs index eedd59e4..767852e9 100644 --- a/src/Flecs.NET/Core/Ecs/Macros.cs +++ b/src/Flecs.NET/Core/Ecs/Macros.cs @@ -315,4 +315,10 @@ internal static ref QueryBuilder GetQueryBuilder(ref T queryBuilder) where T { return ref queryBuilder.QueryBuilder; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static ref ecs_world_t* GetIterableWorld(ref T obj) where T : IIterableBase + { + return ref obj.World; + } } diff --git a/src/Flecs.NET/Core/Field.cs b/src/Flecs.NET/Core/Field.cs index c83d5eae..c568064b 100644 --- a/src/Flecs.NET/Core/Field.cs +++ b/src/Flecs.NET/Core/Field.cs @@ -21,11 +21,6 @@ namespace Flecs.NET.Core; /// public int Length { get; } - /// - /// Specifies if the field is shared. - /// - public bool IsShared { get; } - /// /// Specifies if the field pointer is null. /// @@ -36,12 +31,10 @@ namespace Flecs.NET.Core; /// /// /// - /// - public Field(void* data, int length, bool isShared = false) + public Field(void* data, int length) { Data = data; Length = length; - IsShared = isShared; } /// @@ -53,8 +46,7 @@ public ref T this[int index] [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - Ecs.Assert(index < Length, nameof(ECS_COLUMN_INDEX_OUT_OF_RANGE)); - Ecs.Assert(index == 0 || !IsShared, nameof(ECS_INVALID_PARAMETER)); + Ecs.Assert(index >= 0 && index < Length, nameof(ECS_COLUMN_INDEX_OUT_OF_RANGE)); Ecs.Assert(Data != null, nameof(ECS_COLUMN_INDEX_OUT_OF_RANGE)); return ref Managed.GetTypeRef(Data, index); } @@ -110,4 +102,4 @@ public override int GetHashCode() { return !(left == right); } -} \ No newline at end of file +} diff --git a/src/Flecs.NET/Core/FieldData.cs b/src/Flecs.NET/Core/FieldData.cs new file mode 100644 index 00000000..2d7c3112 --- /dev/null +++ b/src/Flecs.NET/Core/FieldData.cs @@ -0,0 +1,130 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Flecs.NET.Utilities; +using static Flecs.NET.Bindings.flecs; + +namespace Flecs.NET.Core; + +internal unsafe struct FieldData() +{ + public T* Pointer; + public ecs_iter_t* Iter; + public byte Index; // Field index. + public bool IsShared; // Is 0 indexed component. + public bool IsSparse; // Is sparse component. + + public FieldData(ecs_iter_t* iter, byte index) : this() + { + Iter = iter; + Index = index; + + if (Utils.IsBitSet(iter->row_fields, index)) + { + IsSparse = true; + } + else + { + Pointer = (T*)ecs_field_w_size(iter, Type.Size, index); + IsShared = iter->sources[index] != 0 || !Utils.IsBitSet(iter->set_fields, index); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly T* PointerUnmanaged(int row) + { + return &Pointer[row]; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly T* PointerSharedUnmanaged(int row) + { + return IsShared ? PointerUnmanaged(0) : PointerUnmanaged(row); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly T* PointerSparseUnmanaged(int row) + { + return IsSparse ? (T*)ecs_field_at_w_size(Iter, Type.Size, Index, row) : PointerUnmanaged(row); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly T* PointerSparseSharedUnmanaged(int row) + { + return IsSparse ? (T*)ecs_field_at_w_size(Iter, Type.Size, Index, row) : PointerSharedUnmanaged(row); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly T* PointerManaged(int row) + { + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + return (T*)&((GCHandle*)Pointer)[row]; + + return &Pointer[row]; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly T* PointerSharedManaged(int row) + { + return IsShared ? PointerManaged(0) : PointerManaged(row); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly T* PointerSparseManaged(int row) + { + return IsSparse ? (T*)ecs_field_at_w_size(Iter, Type.Size, Index, row) : PointerManaged(row); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly T* PointerSparseSharedManaged(int row) + { + return IsSparse ? (T*)ecs_field_at_w_size(Iter, Type.Size, Index, row) : PointerSharedManaged(row); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly ref T RefUnmanaged(int row) + { + return ref *PointerUnmanaged(row); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly ref T RefSharedUnmanaged(int row) + { + return ref *PointerSharedUnmanaged(row); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly ref T RefSparseUnmanaged(int row) + { + return ref *PointerSparseUnmanaged(row); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly ref T RefSparseSharedUnmanaged(int row) + { + return ref *PointerSparseSharedUnmanaged(row); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly ref T RefManaged(int row) + { + return ref Managed.GetTypeRef(PointerManaged(row)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly ref T RefSharedManaged(int row) + { + return ref Managed.GetTypeRef(PointerSharedManaged(row)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly ref T RefSparseManaged(int row) + { + return ref Managed.GetTypeRef(PointerSparseManaged(row)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public readonly ref T RefSparseSharedManaged(int row) + { + return ref Managed.GetTypeRef(PointerSparseSharedManaged(row)); + } +} diff --git a/src/Flecs.NET/Core/IIterableBase.cs b/src/Flecs.NET/Core/IIterableBase.cs index 88b71ea1..51fd7892 100644 --- a/src/Flecs.NET/Core/IIterableBase.cs +++ b/src/Flecs.NET/Core/IIterableBase.cs @@ -7,6 +7,11 @@ namespace Flecs.NET.Core; /// public unsafe interface IIterableBase { + /// + /// Reference to the world. + /// + public ref ecs_world_t* World { get; } + /// /// Iterate a query. /// diff --git a/src/Flecs.NET/Core/Invoker.cs b/src/Flecs.NET/Core/Invoker.cs index cc05aea1..1f42e02b 100644 --- a/src/Flecs.NET/Core/Invoker.cs +++ b/src/Flecs.NET/Core/Invoker.cs @@ -40,8 +40,6 @@ public static void Each(ecs_iter_t* iter, Ecs.EachEntityCallback callback) { Ecs.Assert(iter->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - iter->flags |= EcsIterCppEach; - Ecs.TableLock(iter->world, iter->table); for (int i = 0; i < iter->count; i++) @@ -57,8 +55,6 @@ public static void Each(ecs_iter_t* iter, Ecs.EachEntityCallback callback) /// public static void Each(ecs_iter_t* iter, Ecs.EachIterCallback callback) { - iter->flags |= EcsIterCppEach; - Ecs.TableLock(iter->world, iter->table); int count = iter->count == 0 && iter->table == null ? 1 : iter->count; @@ -228,8 +224,6 @@ public static void Each(ecs_iter_t* iter, delegate* callback) { Ecs.Assert(iter->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - iter->flags |= EcsIterCppEach; - Ecs.TableLock(iter->world, iter->table); for (int i = 0; i < iter->count; i++) @@ -245,8 +239,6 @@ public static void Each(ecs_iter_t* iter, delegate* callback) /// public static void Each(ecs_iter_t* iter, delegate* callback) { - iter->flags |= EcsIterCppEach; - Ecs.TableLock(iter->world, iter->table); int count = iter->count == 0 && iter->table == null ? 1 : iter->count; @@ -406,4 +398,4 @@ public static void Run(ref T iterable, delegate* callback) where ecs_iter_t iter = iterable.GetIter(); Run(&iter, callback); } -} \ No newline at end of file +} diff --git a/src/Flecs.NET/Core/Iter.cs b/src/Flecs.NET/Core/Iter.cs index 06f293bf..3e0a4ab8 100644 --- a/src/Flecs.NET/Core/Iter.cs +++ b/src/Flecs.NET/Core/Iter.cs @@ -208,7 +208,7 @@ public Entity Entity(int row) public bool IsSelf(int index) { Ecs.Assert(index < Handle->field_count, "Field index out of range."); - return ecs_field_is_self(Handle, index) == 1; + return ecs_field_is_self(Handle, (byte)index) == 1; } /// @@ -219,7 +219,7 @@ public bool IsSelf(int index) public bool IsSet(int index) { Ecs.Assert(index < Handle->field_count, "Field index out of range."); - return ecs_field_is_set(Handle, index) == 1; + return ecs_field_is_set(Handle, (byte)index) == 1; } /// @@ -230,7 +230,7 @@ public bool IsSet(int index) public bool IsReadonly(int index) { Ecs.Assert(index < Handle->field_count, "Field index out of range."); - return ecs_field_is_readonly(Handle, index) == 1; + return ecs_field_is_readonly(Handle, (byte)index) == 1; } /// @@ -250,7 +250,7 @@ public int FieldCount() public ulong Size(int index) { Ecs.Assert(index < Handle->field_count, "Field index out of range."); - return (ulong)ecs_field_size(Handle, index); + return (ulong)ecs_field_size(Handle, (byte)index); } /// @@ -261,7 +261,7 @@ public ulong Size(int index) public Entity Src(int index) { Ecs.Assert(index < Handle->field_count, "Field index out of range."); - return new Entity(Handle->world, ecs_field_src(Handle, index)); + return new Entity(Handle->world, ecs_field_src(Handle, (byte)index)); } /// @@ -272,7 +272,7 @@ public Entity Src(int index) public Id Id(int index) { Ecs.Assert(index < Handle->field_count, "Field index out of range."); - return new Id(Handle->world, ecs_field_id(Handle, index)); + return new Id(Handle->world, ecs_field_id(Handle, (byte)index)); } /// @@ -284,7 +284,7 @@ public Id Id(int index) public Id Pair(int index) { Ecs.Assert(index < Handle->field_count, "Field index out of range."); - ulong id = ecs_field_id(Handle, index); + ulong id = ecs_field_id(Handle, (byte)index); Ecs.Assert(Ecs.EntityHasIdFlag(id, ECS_PAIR) != 0, nameof(ECS_INVALID_PARAMETER)); return new Id(Handle->world, id); } @@ -297,7 +297,7 @@ public Id Pair(int index) public int ColumnIndex(int index) { Ecs.Assert(index < Handle->field_count, "Field index out of range."); - return ecs_field_column(Handle, index); + return ecs_field_column(Handle, (byte)index); } /// @@ -331,7 +331,9 @@ public Field Field(int index) [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T FieldAt(int index, int row) { - return ref GetField(index)[row]; + return ref Utils.IsBitSet(Handle->row_fields, index) + ? ref GetFieldAt(index, row)[0] + : ref GetField(index)[row]; } /// @@ -456,8 +458,18 @@ public void Fini() internal Field GetField(int index) { AssertField(Handle, index); - bool isShared = ecs_field_is_self(Handle, index) == 0; - return new Field(Handle->ptrs[index], isShared ? 1 : Handle->count, isShared); + + return new Field( + ecs_field_w_size(Handle, Type.Size, (byte)index), + ecs_field_is_self(Handle, (byte)index) == Utils.True ? Handle->count : 1 + ); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal Field GetFieldAt(int index, int row) + { + AssertField(Handle, index); + return new Field(ecs_field_at_w_size(Handle, Type.Size, (byte)index, row), 1); } [Conditional("DEBUG")] @@ -676,19 +688,30 @@ internal Span GetSpan(int index) internal T* GetPointer(int index) { AssertField(Handle, index); - return (T*)Handle->ptrs[index]; + return (T*)ecs_field_w_size(Handle, Type.Size, (byte)index); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal int Step(int index) + internal FieldData GetFieldData(byte index) { - return (Handle->sources == null || Handle->sources[index] == 0) && (Handle->set_fields & (1 << index)) != 0 && !Type.IsTag ? Type.Size : 0; + AssertField(Handle, index); + return new FieldData(Handle, index); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal bool IsLinear() + internal IterationTechnique GetIterationTechnique(int fieldCount) { - return Handle->shared_fields == 0 && Handle->set_fields == (1 << Handle->field_count) - 1; + IterationTechnique flags = default; + + int mask = (1 << fieldCount) - 1; + + if ((Handle->row_fields & mask) != 0) + flags |= IterationTechnique.Sparse; + + if (((Handle->ref_fields & mask) != 0 && Handle->ref_fields != Handle->row_fields) || (Handle->up_fields & mask) != 0 || (Handle->set_fields & mask) != mask) + flags |= IterationTechnique.Shared; + + return flags; } } diff --git a/src/Flecs.NET/Core/IterIterable.cs b/src/Flecs.NET/Core/IterIterable.cs index dfad9f9c..c230b972 100644 --- a/src/Flecs.NET/Core/IterIterable.cs +++ b/src/Flecs.NET/Core/IterIterable.cs @@ -299,6 +299,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable { + /// + public ref ecs_world_t* World => ref _iter.world; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Core/IterationTechnique.cs b/src/Flecs.NET/Core/IterationTechnique.cs new file mode 100644 index 00000000..de6ab49c --- /dev/null +++ b/src/Flecs.NET/Core/IterationTechnique.cs @@ -0,0 +1,22 @@ +using System; + +namespace Flecs.NET.Core; + +[Flags] +internal enum IterationTechnique +{ + /// + /// Indicates default enum value. + /// + None = 0, + + /// + /// Indicates that query contains shared components. + /// + Shared = 1, + + /// + /// Indicates that query contains sparse components. + /// + Sparse = 2 +} diff --git a/src/Flecs.NET/Core/PageIterable.cs b/src/Flecs.NET/Core/PageIterable.cs index 8f031acd..b071bb75 100644 --- a/src/Flecs.NET/Core/PageIterable.cs +++ b/src/Flecs.NET/Core/PageIterable.cs @@ -82,6 +82,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable { + /// + public ref ecs_world_t* World => ref _iter.world; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Core/Query.cs b/src/Flecs.NET/Core/Query.cs index e8f9b5ca..5cfe1d1b 100644 --- a/src/Flecs.NET/Core/Query.cs +++ b/src/Flecs.NET/Core/Query.cs @@ -312,6 +312,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query { + /// + ref ecs_world_t* IIterableBase.World => ref _handle->world; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Core/WorkerIterable.cs b/src/Flecs.NET/Core/WorkerIterable.cs index 53d5c817..28eefa7b 100644 --- a/src/Flecs.NET/Core/WorkerIterable.cs +++ b/src/Flecs.NET/Core/WorkerIterable.cs @@ -82,6 +82,9 @@ public override int GetHashCode() //IIterableBase Interface public unsafe partial struct WorkerIterable { + /// + public ref ecs_world_t* World => ref _iter.world; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Flecs.NET.csproj b/src/Flecs.NET/Flecs.NET.csproj index baa6877b..01c974a9 100644 --- a/src/Flecs.NET/Flecs.NET.csproj +++ b/src/Flecs.NET/Flecs.NET.csproj @@ -20,7 +20,7 @@ true true - 4.0.0 + 4.0.1 Flecs.NET.Debug Flecs.NET.Release BeanCheeseBurrito diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T1.g.cs index cd3c5e5e..cae85205 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T1.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T1.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ecs.EachRefCallback callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback(ref Managed.GetTypeRef(pointer0)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ecs.EachEntityRefCallback callback) { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ecs.EachIterRefCallback callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback(it, i, ref Managed.GetTypeRef(pointer0)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, delegate* callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback(ref Managed.GetTypeRef(pointer0)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, delegate* callback) { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, delegate* callback { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback(it, i, ref Managed.GetTypeRef(pointer0)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ecs.EachPointerCallback callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback((T0*)pointer0); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ecs.EachEntityPointerCallback callback) { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ecs.EachIterPointerCallback callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback(it, i, (T0*)pointer0); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, delegate* callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback((T0*)pointer0); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, delegate* callback) { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, delegate* callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) - callback(it, i, (T0*)pointer0); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T10.g.cs index b5534e21..da7c9e0b 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T10.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T10.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ecs.Eac { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ecs.Eac { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ecs.Eac { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, delegat { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, delegat { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, delegat { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ecs.Eac { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ecs.Eac { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ecs.Eac { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, delegat { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, delegat { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, delegat { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T11.g.cs index 7bfc51c8..3e4c2830 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T11.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T11.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ec { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ec { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ec { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, de { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, de { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, de { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ec { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ec { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ec { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, de { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, de { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, de { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T12.g.cs index dd16c30e..5359040a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T12.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T12.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter i { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter i { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter i { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter i { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter i { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter i { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter i { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter i { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter i { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter i { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter i { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter i { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T13.g.cs index b03f8aae..c5706a17 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T13.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T13.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(I { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(I { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(I { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(I { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(I { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(I { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(I { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(I { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(I { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(I { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(I { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(I { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T14.g.cs index 118bf50c..65d7b225 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T14.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T14.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T15.g.cs index 34029ada..75955ca4 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T15.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T15.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T16.g.cs index 27139a45..e4fa177a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T16.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T16.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Eachcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Eachcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T2.g.cs index 78488736..b8bd95f1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T2.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T2.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ecs.EachRefCallback callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ecs.EachEntityRefCallback callb { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ecs.EachIterRefCallback callbac { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, delegate* callbac { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, delegate* { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ecs.EachPointerCallback callbac { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback((T0*)pointer0, (T1*)pointer1); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ecs.EachEntityPointerCallback c { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ecs.EachIterPointerCallback cal { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback(it, i, (T0*)pointer0, (T1*)pointer1); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, delegate* callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback((T0*)pointer0, (T1*)pointer1); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, delegate* callb { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, delegate* ca { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) - callback(it, i, (T0*)pointer0, (T1*)pointer1); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T3.g.cs index 766bd6a7..17c5033a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T3.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T3.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ecs.EachRefCallback cal { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ecs.EachEntityRefCallbackcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ecs.EachIterRefCallback { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ecs.EachPointerCallback { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ecs.EachEntityPointerCallbackcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ecs.EachIterPointerCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, delegate* call { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T4.g.cs index 8987a2a5..9cf37b1c 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T4.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T4.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ecs.EachRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ecs.EachEntityRefCallbackcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ecs.EachIterRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ecs.EachPointerCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ecs.EachEntityPointerCallbackcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ecs.EachIterPointerCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T5.g.cs index 6177839d..8222c569 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T5.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T5.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ecs.EachRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ecs.EachEntityRefCallbackcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ecs.EachIterRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ecs.EachPointerCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ecs.EachEntityPointerCallba { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ecs.EachIterPointerCallback { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T6.g.cs index a7c357b6..02adc970 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T6.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T6.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ecs.EachRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ecs.EachEntityRefCallba { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ecs.EachIterRefCallback { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ecs.EachPointerCallback { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ecs.EachEntityPointerCa { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ecs.EachIterPointerCall { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T7.g.cs index 186000ea..230e1060 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T7.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T7.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ecs.EachRefCallback { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ecs.EachEntityRefCa { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ecs.EachIterRefCall { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ecs.EachPointerCall { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ecs.EachEntityPoint { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ecs.EachIterPointer { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T8.g.cs index 8bb05d21..fe4daad1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T8.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T8.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ecs.EachRefCall { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ecs.EachEntityR { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ecs.EachIterRef { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ecs.EachPointer { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ecs.EachEntityP { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ecs.EachIterPoi { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T9.g.cs index 6f91c90c..1698a279 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Each/Iterator/T9.g.cs @@ -1,5 +1,7 @@ // Each/Iterator/T9.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,15 +19,93 @@ public static void Each(Iter it, Ecs.EachRef { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i)); + } } /// @@ -38,15 +118,93 @@ public static void Each(Iter it, Ecs.EachEnt { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i)); + } } /// @@ -59,15 +217,93 @@ public static void Each(Iter it, Ecs.EachIte { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i)); + } } /// @@ -80,15 +316,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i)); + } } /// @@ -101,15 +415,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i)); + } } /// @@ -122,15 +514,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8)); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i)); + } } /// @@ -143,15 +613,93 @@ public static void Each(Iter it, Ecs.EachPoi { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i)); + } } /// @@ -164,15 +712,93 @@ public static void Each(Iter it, Ecs.EachEnt { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i)); + } } /// @@ -185,15 +811,93 @@ public static void Each(Iter it, Ecs.EachIte { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, Ecs.EachIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i)); + } } /// @@ -206,15 +910,93 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i)); + } } /// @@ -227,15 +1009,93 @@ public static void Each(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i)); + } } /// @@ -248,14 +1108,92 @@ public static void Each(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) - callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8); + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) + { + if (flags == IterationTechnique.None) + Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } Ecs.TableUnlock(it); + + return; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i)); + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T1.g.cs index 4ba025c4..5fd1fed6 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T1.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T1.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, Ecs.FindRefCallback callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, Ecs.FindEntityRefCallback callback) { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, Ecs.FindIterRefCallback callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, delegate* callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, delegate* callback) { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, delegate* callba { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, Ecs.FindPointerCallback callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, Ecs.FindEntityPointerCallback callbac { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, Ecs.FindIterPointerCallback callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, delegate* callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, delegate* callback) { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, delegate* callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); - int step0 = it.Step(0); + FieldData field0 = it.GetFieldData(0); + IterationTechnique flags = it.GetIterationTechnique(1); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T10.g.cs index 275adb7d..b6055bfa 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T10.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T10.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, Ecs.F { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, Ecs.F { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, Ecs.F { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, deleg { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, deleg { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, deleg { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, Ecs.F { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, Ecs.F { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, Ecs.F { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, deleg { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, deleg { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, deleg { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); + IterationTechnique flags = it.GetIterationTechnique(10); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T11.g.cs index e4dc67f8..52aa5ec2 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T11.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T11.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); + IterationTechnique flags = it.GetIterationTechnique(11); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T12.g.cs index 4bc15f05..d9fa81a8 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T12.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T12.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); + IterationTechnique flags = it.GetIterationTechnique(12); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T13.g.cs index 75b4cdc7..da1379bc 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T13.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T13.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); + IterationTechnique flags = it.GetIterationTechnique(13); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T14.g.cs index ef58d99b..fce35976 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T14.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T14.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); + IterationTechnique flags = it.GetIterationTechnique(14); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T15.g.cs index 1410fcb6..4fcca619 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T15.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T15.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); + IterationTechnique flags = it.GetIterationTechnique(15); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T16.g.cs index 77f0d473..afc649be 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T16.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T16.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8), ref Managed.GetTypeRef(pointer9), ref Managed.GetTypeRef(pointer10), ref Managed.GetTypeRef(pointer11), ref Managed.GetTypeRef(pointer12), ref Managed.GetTypeRef(pointer13), ref Managed.GetTypeRef(pointer14), ref Managed.GetTypeRef(pointer15))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i), ref field9.RefUnmanaged(i), ref field10.RefUnmanaged(i), ref field11.RefUnmanaged(i), ref field12.RefUnmanaged(i), ref field13.RefUnmanaged(i), ref field14.RefUnmanaged(i), ref field15.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i), ref field9.RefSharedUnmanaged(i), ref field10.RefSharedUnmanaged(i), ref field11.RefSharedUnmanaged(i), ref field12.RefSharedUnmanaged(i), ref field13.RefSharedUnmanaged(i), ref field14.RefSharedUnmanaged(i), ref field15.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i), ref field9.RefSparseUnmanaged(i), ref field10.RefSparseUnmanaged(i), ref field11.RefSparseUnmanaged(i), ref field12.RefSparseUnmanaged(i), ref field13.RefSparseUnmanaged(i), ref field14.RefSparseUnmanaged(i), ref field15.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i), ref field9.RefSparseSharedUnmanaged(i), ref field10.RefSparseSharedUnmanaged(i), ref field11.RefSparseSharedUnmanaged(i), ref field12.RefSparseSharedUnmanaged(i), ref field13.RefSparseSharedUnmanaged(i), ref field14.RefSparseSharedUnmanaged(i), ref field15.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i), ref field9.RefManaged(i), ref field10.RefManaged(i), ref field11.RefManaged(i), ref field12.RefManaged(i), ref field13.RefManaged(i), ref field14.RefManaged(i), ref field15.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i), ref field9.RefSharedManaged(i), ref field10.RefSharedManaged(i), ref field11.RefSharedManaged(i), ref field12.RefSharedManaged(i), ref field13.RefSharedManaged(i), ref field14.RefSharedManaged(i), ref field15.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i), ref field9.RefSparseManaged(i), ref field10.RefSparseManaged(i), ref field11.RefSparseManaged(i), ref field12.RefSparseManaged(i), ref field13.RefSparseManaged(i), ref field14.RefSparseManaged(i), ref field15.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i), ref field9.RefSparseSharedManaged(i), ref field10.RefSparseSharedManaged(i), ref field11.RefSparseSharedManaged(i), ref field12.RefSparseSharedManaged(i), ref field13.RefSparseSharedManaged(i), ref field14.RefSparseSharedManaged(i), ref field15.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Findcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Findcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); byte* pointer9 = (byte*)it.GetPointer(9); byte* pointer10 = (byte*)it.GetPointer(10); byte* pointer11 = (byte*)it.GetPointer(11); byte* pointer12 = (byte*)it.GetPointer(12); byte* pointer13 = (byte*)it.GetPointer(13); byte* pointer14 = (byte*)it.GetPointer(14); byte* pointer15 = (byte*)it.GetPointer(15); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); int step9 = it.Step(9); int step10 = it.Step(10); int step11 = it.Step(11); int step12 = it.Step(12); int step13 = it.Step(13); int step14 = it.Step(14); int step15 = it.Step(15); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); FieldData field9 = it.GetFieldData(9); FieldData field10 = it.GetFieldData(10); FieldData field11 = it.GetFieldData(11); FieldData field12 = it.GetFieldData(12); FieldData field13 = it.GetFieldData(13); FieldData field14 = it.GetFieldData(14); FieldData field15 = it.GetFieldData(15); + IterationTechnique flags = it.GetIterationTechnique(16); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8], pointer9 = &pointer9[step9], pointer10 = &pointer10[step10], pointer11 = &pointer11[step11], pointer12 = &pointer12[step12], pointer13 = &pointer13[step13], pointer14 = &pointer14[step14], pointer15 = &pointer15[step15]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8, (T9*)pointer9, (T10*)pointer10, (T11*)pointer11, (T12*)pointer12, (T13*)pointer13, (T14*)pointer14, (T15*)pointer15)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8, ref field9, ref field10, ref field11, ref field12, ref field13, ref field14, ref field15); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i), field9.PointerUnmanaged(i), field10.PointerUnmanaged(i), field11.PointerUnmanaged(i), field12.PointerUnmanaged(i), field13.PointerUnmanaged(i), field14.PointerUnmanaged(i), field15.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i), field9.PointerSharedUnmanaged(i), field10.PointerSharedUnmanaged(i), field11.PointerSharedUnmanaged(i), field12.PointerSharedUnmanaged(i), field13.PointerSharedUnmanaged(i), field14.PointerSharedUnmanaged(i), field15.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i), field9.PointerSparseUnmanaged(i), field10.PointerSparseUnmanaged(i), field11.PointerSparseUnmanaged(i), field12.PointerSparseUnmanaged(i), field13.PointerSparseUnmanaged(i), field14.PointerSparseUnmanaged(i), field15.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i), field9.PointerSparseSharedUnmanaged(i), field10.PointerSparseSharedUnmanaged(i), field11.PointerSparseSharedUnmanaged(i), field12.PointerSparseSharedUnmanaged(i), field13.PointerSparseSharedUnmanaged(i), field14.PointerSparseSharedUnmanaged(i), field15.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i), field9.PointerManaged(i), field10.PointerManaged(i), field11.PointerManaged(i), field12.PointerManaged(i), field13.PointerManaged(i), field14.PointerManaged(i), field15.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i), field9.PointerSharedManaged(i), field10.PointerSharedManaged(i), field11.PointerSharedManaged(i), field12.PointerSharedManaged(i), field13.PointerSharedManaged(i), field14.PointerSharedManaged(i), field15.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i), field9.PointerSparseManaged(i), field10.PointerSparseManaged(i), field11.PointerSparseManaged(i), field12.PointerSparseManaged(i), field13.PointerSparseManaged(i), field14.PointerSparseManaged(i), field15.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8, ref FieldData field9, ref FieldData field10, ref FieldData field11, ref FieldData field12, ref FieldData field13, ref FieldData field14, ref FieldData field15) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i), field9.PointerSparseSharedManaged(i), field10.PointerSparseSharedManaged(i), field11.PointerSparseSharedManaged(i), field12.PointerSparseSharedManaged(i), field13.PointerSparseSharedManaged(i), field14.PointerSparseSharedManaged(i), field15.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T2.g.cs index ba881258..93490c09 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T2.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T2.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, Ecs.FindRefCallback callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, Ecs.FindEntityRefCallback cal { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, Ecs.FindIterRefCallback callb { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, delegate* callb { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, Ecs.FindPointerCallback callb { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, Ecs.FindEntityPointerCallback { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, Ecs.FindIterPointerCallback c { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, delegate* callback) { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, delegate* cal { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, delegate* { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); - int step0 = it.Step(0); int step1 = it.Step(1); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); + IterationTechnique flags = it.GetIterationTechnique(2); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T3.g.cs index 70ccfb33..004109da 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T3.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T3.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, Ecs.FindRefCallback c { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, Ecs.FindEntityRefCallbackcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, Ecs.FindIterRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, Ecs.FindPointerCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, Ecs.FindEntityPointerCallbackcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, Ecs.FindIterPointerCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, delegate* ca { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); + IterationTechnique flags = it.GetIterationTechnique(3); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T4.g.cs index f304b0cf..3bad6114 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T4.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T4.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, Ecs.FindRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, Ecs.FindEntityRefCallbackcount; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, Ecs.FindIterRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, Ecs.FindPointerCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, Ecs.FindEntityPointerCallback { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, Ecs.FindIterPointerCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); + IterationTechnique flags = it.GetIterationTechnique(4); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T5.g.cs index 1a3326fd..e3ecb00f 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T5.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T5.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, Ecs.FindRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, Ecs.FindEntityRefCallback { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, Ecs.FindIterRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, Ecs.FindPointerCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, Ecs.FindEntityPointerCall { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, Ecs.FindIterPointerCallba { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); + IterationTechnique flags = it.GetIterationTechnique(5); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T6.g.cs index fc956b19..beface4b 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T6.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T6.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, Ecs.FindRefCallbackcount == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, Ecs.FindEntityRefCall { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, Ecs.FindIterRefCallba { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, Ecs.FindPointerCallba { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, Ecs.FindEntityPointer { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, Ecs.FindIterPointerCa { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); + IterationTechnique flags = it.GetIterationTechnique(6); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T7.g.cs index 8d6482df..6877284a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T7.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T7.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, Ecs.FindRefCallba { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, Ecs.FindEntityRef { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, Ecs.FindIterRefCa { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, Ecs.FindPointerCa { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, Ecs.FindEntityPoi { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, Ecs.FindIterPoint { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); + IterationTechnique flags = it.GetIterationTechnique(7); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T8.g.cs index d1d0f073..899e85d8 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T8.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T8.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, Ecs.FindRefCa { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, Ecs.FindEntit { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, Ecs.FindIterR { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, Ecs.FindPoint { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, Ecs.FindEntit { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, Ecs.FindIterP { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, delegate*count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, delegate*count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); + IterationTechnique flags = it.GetIterationTechnique(8); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T9.g.cs index 8f830ae6..046be269 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Invoker/Find/Iterator/T9.g.cs @@ -1,5 +1,7 @@ // Find/Iterator/T9.g.cs // File was auto-generated by /_/src/Flecs.NET.Codegen/Generators/Invoker.cs +using System; +using System.Runtime.CompilerServices; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -17,25 +19,135 @@ public static Entity Find(Iter it, Ecs.FindR { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -48,25 +160,135 @@ public static Entity Find(Iter it, Ecs.FindE { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -79,25 +301,135 @@ public static Entity Find(Iter it, Ecs.FindI { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterRefCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -110,25 +442,135 @@ public static Entity Find(Iter it, delegate* { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -141,25 +583,135 @@ public static Entity Find(Iter it, delegate* { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -172,25 +724,135 @@ public static Entity Find(Iter it, delegate* { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, ref Managed.GetTypeRef(pointer0), ref Managed.GetTypeRef(pointer1), ref Managed.GetTypeRef(pointer2), ref Managed.GetTypeRef(pointer3), ref Managed.GetTypeRef(pointer4), ref Managed.GetTypeRef(pointer5), ref Managed.GetTypeRef(pointer6), ref Managed.GetTypeRef(pointer7), ref Managed.GetTypeRef(pointer8))) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefUnmanaged(i), ref field1.RefUnmanaged(i), ref field2.RefUnmanaged(i), ref field3.RefUnmanaged(i), ref field4.RefUnmanaged(i), ref field5.RefUnmanaged(i), ref field6.RefUnmanaged(i), ref field7.RefUnmanaged(i), ref field8.RefUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedUnmanaged(i), ref field1.RefSharedUnmanaged(i), ref field2.RefSharedUnmanaged(i), ref field3.RefSharedUnmanaged(i), ref field4.RefSharedUnmanaged(i), ref field5.RefSharedUnmanaged(i), ref field6.RefSharedUnmanaged(i), ref field7.RefSharedUnmanaged(i), ref field8.RefSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseUnmanaged(i), ref field1.RefSparseUnmanaged(i), ref field2.RefSparseUnmanaged(i), ref field3.RefSparseUnmanaged(i), ref field4.RefSparseUnmanaged(i), ref field5.RefSparseUnmanaged(i), ref field6.RefSparseUnmanaged(i), ref field7.RefSparseUnmanaged(i), ref field8.RefSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedUnmanaged(i), ref field1.RefSparseSharedUnmanaged(i), ref field2.RefSparseSharedUnmanaged(i), ref field3.RefSparseSharedUnmanaged(i), ref field4.RefSparseSharedUnmanaged(i), ref field5.RefSparseSharedUnmanaged(i), ref field6.RefSparseSharedUnmanaged(i), ref field7.RefSparseSharedUnmanaged(i), ref field8.RefSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefManaged(i), ref field1.RefManaged(i), ref field2.RefManaged(i), ref field3.RefManaged(i), ref field4.RefManaged(i), ref field5.RefManaged(i), ref field6.RefManaged(i), ref field7.RefManaged(i), ref field8.RefManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSharedManaged(i), ref field1.RefSharedManaged(i), ref field2.RefSharedManaged(i), ref field3.RefSharedManaged(i), ref field4.RefSharedManaged(i), ref field5.RefSharedManaged(i), ref field6.RefSharedManaged(i), ref field7.RefSharedManaged(i), ref field8.RefSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseManaged(i), ref field1.RefSparseManaged(i), ref field2.RefSparseManaged(i), ref field3.RefSparseManaged(i), ref field4.RefSparseManaged(i), ref field5.RefSparseManaged(i), ref field6.RefSparseManaged(i), ref field7.RefSparseManaged(i), ref field8.RefSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, ref field0.RefSparseSharedManaged(i), ref field1.RefSparseSharedManaged(i), ref field2.RefSparseSharedManaged(i), ref field3.RefSparseSharedManaged(i), ref field4.RefSparseSharedManaged(i), ref field5.RefSparseSharedManaged(i), ref field6.RefSparseSharedManaged(i), ref field7.RefSparseSharedManaged(i), ref field8.RefSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -203,25 +865,135 @@ public static Entity Find(Iter it, Ecs.FindP { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -234,25 +1006,135 @@ public static Entity Find(Iter it, Ecs.FindE { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindEntityPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -265,25 +1147,135 @@ public static Entity Find(Iter it, Ecs.FindI { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, Ecs.FindIterPointerCallback callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -296,25 +1288,135 @@ public static Entity Find(Iter it, delegate* { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback((T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -327,25 +1429,135 @@ public static Entity Find(Iter it, delegate* { int count = it.Handle->count; Ecs.Assert(it.Handle->count > 0, "No entities returned, use Iter() or Each() without the entity argument instead."); - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(new Entity(it.Handle->world, it.Handle->entities[i]), (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(new Entity(it.Handle->world, it.Handle->entities[i]), field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } /// @@ -358,24 +1570,134 @@ public static Entity Find(Iter it, delegate* { int count = it.Handle->count == 0 && it.Handle->table == null ? 1 : it.Handle->count; - byte* pointer0 = (byte*)it.GetPointer(0); byte* pointer1 = (byte*)it.GetPointer(1); byte* pointer2 = (byte*)it.GetPointer(2); byte* pointer3 = (byte*)it.GetPointer(3); byte* pointer4 = (byte*)it.GetPointer(4); byte* pointer5 = (byte*)it.GetPointer(5); byte* pointer6 = (byte*)it.GetPointer(6); byte* pointer7 = (byte*)it.GetPointer(7); byte* pointer8 = (byte*)it.GetPointer(8); - int step0 = it.Step(0); int step1 = it.Step(1); int step2 = it.Step(2); int step3 = it.Step(3); int step4 = it.Step(4); int step5 = it.Step(5); int step6 = it.Step(6); int step7 = it.Step(7); int step8 = it.Step(8); + FieldData field0 = it.GetFieldData(0); FieldData field1 = it.GetFieldData(1); FieldData field2 = it.GetFieldData(2); FieldData field3 = it.GetFieldData(3); FieldData field4 = it.GetFieldData(4); FieldData field5 = it.GetFieldData(5); FieldData field6 = it.GetFieldData(6); FieldData field7 = it.GetFieldData(7); FieldData field8 = it.GetFieldData(8); + IterationTechnique flags = it.GetIterationTechnique(9); Ecs.TableLock(it); Entity result = default; - - for (int i = 0; i < count; i++, pointer0 = &pointer0[step0], pointer1 = &pointer1[step1], pointer2 = &pointer2[step2], pointer3 = &pointer3[step3], pointer4 = &pointer4[step4], pointer5 = &pointer5[step5], pointer6 = &pointer6[step6], pointer7 = &pointer7[step7], pointer8 = &pointer8[step8]) + + if (RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences() || RuntimeHelpers.IsReferenceOrContainsReferences()) { - if (!callback(it, i, (T0*)pointer0, (T1*)pointer1, (T2*)pointer2, (T3*)pointer3, (T4*)pointer4, (T5*)pointer5, (T6*)pointer6, (T7*)pointer7, (T8*)pointer8)) - continue; - - result = new Entity(it.Handle->world, it.Handle->entities[i]); - break; + if (flags == IterationTechnique.None) + result = Managed(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedManaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + } + else + { + if (flags == IterationTechnique.None) + result = Unmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Shared) + result = SharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == IterationTechnique.Sparse) + result = SparseUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); + else if (flags == (IterationTechnique.Sparse | IterationTechnique.Shared)) + result = SparseSharedUnmanaged(it, count, callback, ref field0, ref field1, ref field2, ref field3, ref field4, ref field5, ref field6, ref field7, ref field8); } Ecs.TableUnlock(it); return result; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Unmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerUnmanaged(i), field1.PointerUnmanaged(i), field2.PointerUnmanaged(i), field3.PointerUnmanaged(i), field4.PointerUnmanaged(i), field5.PointerUnmanaged(i), field6.PointerUnmanaged(i), field7.PointerUnmanaged(i), field8.PointerUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedUnmanaged(i), field1.PointerSharedUnmanaged(i), field2.PointerSharedUnmanaged(i), field3.PointerSharedUnmanaged(i), field4.PointerSharedUnmanaged(i), field5.PointerSharedUnmanaged(i), field6.PointerSharedUnmanaged(i), field7.PointerSharedUnmanaged(i), field8.PointerSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseUnmanaged(i), field1.PointerSparseUnmanaged(i), field2.PointerSparseUnmanaged(i), field3.PointerSparseUnmanaged(i), field4.PointerSparseUnmanaged(i), field5.PointerSparseUnmanaged(i), field6.PointerSparseUnmanaged(i), field7.PointerSparseUnmanaged(i), field8.PointerSparseUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedUnmanaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedUnmanaged(i), field1.PointerSparseSharedUnmanaged(i), field2.PointerSparseSharedUnmanaged(i), field3.PointerSparseSharedUnmanaged(i), field4.PointerSparseSharedUnmanaged(i), field5.PointerSparseSharedUnmanaged(i), field6.PointerSparseSharedUnmanaged(i), field7.PointerSparseSharedUnmanaged(i), field8.PointerSparseSharedUnmanaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity Managed(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerManaged(i), field1.PointerManaged(i), field2.PointerManaged(i), field3.PointerManaged(i), field4.PointerManaged(i), field5.PointerManaged(i), field6.PointerManaged(i), field7.PointerManaged(i), field8.PointerManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSharedManaged(i), field1.PointerSharedManaged(i), field2.PointerSharedManaged(i), field3.PointerSharedManaged(i), field4.PointerSharedManaged(i), field5.PointerSharedManaged(i), field6.PointerSharedManaged(i), field7.PointerSharedManaged(i), field8.PointerSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseManaged(i), field1.PointerSparseManaged(i), field2.PointerSparseManaged(i), field3.PointerSparseManaged(i), field4.PointerSparseManaged(i), field5.PointerSparseManaged(i), field6.PointerSparseManaged(i), field7.PointerSparseManaged(i), field8.PointerSparseManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Entity SparseSharedManaged(Iter it, int count, delegate* callback, ref FieldData field0, ref FieldData field1, ref FieldData field2, ref FieldData field3, ref FieldData field4, ref FieldData field5, ref FieldData field6, ref FieldData field7, ref FieldData field8) + { + for (int i = 0; i < count; i++) + { + if (callback(it, i, field0.PointerSparseSharedManaged(i), field1.PointerSparseSharedManaged(i), field2.PointerSparseSharedManaged(i), field3.PointerSparseSharedManaged(i), field4.PointerSparseSharedManaged(i), field5.PointerSparseSharedManaged(i), field6.PointerSparseSharedManaged(i), field7.PointerSparseSharedManaged(i), field8.PointerSparseSharedManaged(i))) + return new Entity(it.Handle->world, it.Handle->entities[i]); + } + + return default; + } } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T1.g.cs index f8222337..3ece1caa 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T1.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, void> callback) public void Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T10.g.cs index 88c58d69..b3c26321 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T10.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback c public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback ca public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback cal public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback c public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T11.g.cs index 8e36aa60..e4078492 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T11.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T12.g.cs index 4e50e0e1..8d66503d 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T12.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T13.g.cs index 498d0c57..a1660c24 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T13.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T14.g.cs index 8f87bdfc..1b56ba6c 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T14.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T15.g.cs index 4fd8ddd3..146ea919 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T15.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T16.g.cs index 8cb7ed2f..02f0d952 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T16.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T2.g.cs index 51b6b4a8..8e1d8110 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T2.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, void> callback) public void Iter(delegate*, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T3.g.cs index 5e2757f3..2e5d2b52 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T3.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, void> callback public void Iter(delegate*, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T4.g.cs index b48668d1..0f0cc9bd 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T4.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, voi public void Iter(delegate*, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, void> c public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* call public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* ca public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T5.g.cs index 716873dd..cbb6cbdb 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T5.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T6.g.cs index 9f44aaa7..b191e362 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T6.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callba public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callbac public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callbac public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T7.g.cs index 5e60a2d1..ecf8c84c 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T7.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callba public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callb public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* call public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* c public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callbac public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback cal public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* ca public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T8.g.cs index fae7bff6..5023e9eb 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T8.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callbac public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* c public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callb public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callbac public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback c public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback cal public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback cal public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callb public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback c public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T9.g.cs index e6b1c06e..e2c13dec 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable.IIterable/T9.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct IterIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callb public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callba public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback cal public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callbac public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback c public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback cal public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback cal public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* ca public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callb public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback c public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback c public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T1.g.cs index aed9f63b..41201019 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T1.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T10.g.cs index b1d565e4..577bf055 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T10.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T11.g.cs index cf4eb987..05660749 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T11.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T12.g.cs index 84689098..d4eedb05 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T12.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T13.g.cs index 08d853df..7eb478ad 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T13.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T14.g.cs index 5b6ba2e0..cf672922 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T14.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T15.g.cs index 45e04dc8..c78a8056 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T15.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T16.g.cs index 3b291697..ebaf3e3f 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T16.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T2.g.cs index b18392af..50f9bbf6 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T2.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T3.g.cs index 4ba6a270..0b75d025 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T3.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T4.g.cs index 567198c6..d095358a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T4.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T5.g.cs index a2c907ef..f13deaaf 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T5.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T6.g.cs index e8806a48..257f5f8b 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T6.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T7.g.cs index 3f0a342d..6795fce1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T7.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T8.g.cs index e1275de5..7e29d704 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T8.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T9.g.cs index 18770a1d..de331177 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/IterIterable/IterIterable/T9.g.cs @@ -150,6 +150,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct IterIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _iterIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T1.g.cs index fe0bda26..90bc2af6 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T1.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder public Observer Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback callback) public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* callback) public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldCallback callback) public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCallback callback) public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointerCallback callback) public Observer Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate*, void> callback) public Observer Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate*, void> callback) public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* callback) public Observer Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCallback callback) public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntityRefCallback callback) public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRefCallback callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* callback) public Observer Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointerCallback callback) public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntityPointerCallback callback) public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPointerCallback callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T10.g.cs index b735af32..eb6343bf 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T10.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback call public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldCallba public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCallbac public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointerCall public Observer Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate* Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate* Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCallback public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntityRefCa public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRefCall public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointerCall public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntityPoint public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPointer public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T11.g.cs index c16013a0..c279c053 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T11.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldC public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCa public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointe public Observer Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate* Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate* Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCal public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntity public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRe public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointe public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntity public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPo public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T12.g.cs index e651e8e8..bb71f060 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T12.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCal public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate*< public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterF public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterS public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterP public Observer Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate* public Observer Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate* public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* public Observer Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachR public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachE public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachI public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* public Observer Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachP public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachE public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachI public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T13.g.cs index d33bb8e3..a9dba17a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T13.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.R public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(deleg public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs. public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs. public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs. public Observer Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(dele public Observer Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(dele public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(dele public Observer Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs. public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs. public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs. public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(dele public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(dele public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(dele public Observer Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs. public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs. public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs. public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(dele public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(dele public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T14.g.cs index 4d3f489f..99b7cfc8 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T14.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run( public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run( public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter public Observer Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter public Observer Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter public Observer Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each public Observer Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T15.g.cs index 9adff94a..b1253516 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T15.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer public Observer Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer public Observer Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer public Observer Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer public Observer Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T16.g.cs index 549f5cd5..17055e3f 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T16.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T2.g.cs index cd9e5257..18beb7a2 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T2.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder public Observer Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback callback) public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* callback) public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldCallback callback) public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCallback callback) public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointerCallback callback) public Observer Iter(delegate*, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate*, Field, void> callbac public Observer Iter(delegate*, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate*, Span, void> callback) public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* callback) public Observer Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCallback callback) public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntityRefCallback callback) public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRefCallback callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* callback public Observer Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointerCallback callback) public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntityPointerCallback callback) public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPointerCallback callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T3.g.cs index b1915330..10a240d3 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T3.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder public Observer Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback callback) public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* callback) public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldCallback callback) public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCallback callback) public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointerCallback callback) public Observer Iter(delegate*, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate*, Field, Field public Observer Iter(delegate*, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate*, Span, Span, v public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* callback) public Observer Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCallback callback) public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntityRefCallback callback) public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRefCallback callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* callbac public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointerCallback callback) public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntityPointerCallback callb public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPointerCallback callbac public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* callback) public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* callback public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T4.g.cs index 0fbde475..1668134c 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T4.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder public Observer Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback callback) public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* callback) public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldCallback callb public Observer Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCallback callba public Observer Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointerCallback cal public Observer Iter(delegate*, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate*, Field, Field public Observer Iter(delegate*, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate*, Span, Span Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* c public Observer Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCallback callbac public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntityRefCallback c public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRefCallback cal public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointerCallback cal public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntityPointerCallback Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPointerCallback public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* callbac public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T5.g.cs index 59cad492..5bfac7a1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T5.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder public Observer Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback callback) public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* callback) public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldCallback Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCallback Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointerCallback Iter(delegate*, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate*, Field, F public Observer Iter(delegate*, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate*, Span, Spa public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCallback public Observer Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntityRefCallback Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRefCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointerCallback Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntityPointerCallback Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPointerCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T6.g.cs index 4fd082c0..5cbcff22 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T6.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder public Observer Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback callback) public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* callback) public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldCallback Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCallback Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointerCallback Iter(delegate*, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate*, Field Iter(delegate*, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate*, Span, public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCallback Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntityRefCallback Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRefCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointerCallback Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntityPointerCallback Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPointerCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T7.g.cs index 7089c5e2..617ce75a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T7.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder public Observer Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback callback) public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* callback) public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldCallback Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCallback Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointerCallback Iter(delegate*, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate*, Fiel public Observer Iter(delegate*, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate*, Span< public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCallback Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntityRefCallback Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRefCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointerCallback Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntityPointerCallback Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPointerCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T8.g.cs index 69f1a32b..81b4db05 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T8.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder public Observer Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback callback) public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* callba public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldCallback Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCallback Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointerCallback Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate*, public Observer Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate*, S public Observer Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCallback Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntityRefCallback Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRefCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointerCallback Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntityPointerCallba public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPointerCallback public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T9.g.cs index 6fb446d3..964afa06 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/ObserverBuilder/ObserverBuilder.NodeBuilder/T9.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct ObserverBuilder public Observer Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public Observer Run(Ecs.RunCallback callback public Observer Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public Observer Run(delegate* ca public Observer Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public Observer Iter(Ecs.IterFieldCallback Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public Observer Iter(Ecs.IterSpanCallback Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public Observer Iter(Ecs.IterPointerCallback public Observer Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public Observer Iter(delegate* Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public Observer Iter(delegate* Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public Observer Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public Observer Each(Ecs.EachRefCallback Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public Observer Each(Ecs.EachEntityRefCallba public Observer Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public Observer Each(Ecs.EachIterRefCallback public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public Observer Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public Observer Each(Ecs.EachPointerCallback public Observer Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public Observer Each(Ecs.EachEntityPointerCa public Observer Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public Observer Each(Ecs.EachIterPointerCall public Observer Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public Observer Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T1.g.cs index 8904dbdb..3dc6ffde 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T1.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, void> callback) public void Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T10.g.cs index ca01ecda..57f9ad10 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T10.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback c public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback ca public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback cal public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback c public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T11.g.cs index 32bae477..141d9dfc 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T11.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T12.g.cs index 1b4aeded..70499f20 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T12.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T13.g.cs index 9a6ac4de..03eb1a82 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T13.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T14.g.cs index 67593d04..8b833a19 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T14.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T15.g.cs index 9e129e3b..c7007615 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T15.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T16.g.cs index 07a9828c..ae714a8e 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T16.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T2.g.cs index 05b9dca6..cbbc612e 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T2.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, void> callback) public void Iter(delegate*, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T3.g.cs index ad775c5a..ad35011a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T3.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, void> callback public void Iter(delegate*, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T4.g.cs index 5e455699..f57a9d89 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T4.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, voi public void Iter(delegate*, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, void> c public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* call public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* ca public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T5.g.cs index 2783e1fe..57aef335 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T5.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T6.g.cs index 9a452a55..4d9491b0 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T6.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callba public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callbac public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callbac public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T7.g.cs index de5dde72..2e838fff 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T7.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callba public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callb public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* call public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* c public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callbac public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback cal public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* ca public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T8.g.cs index 5eda67f3..3c5f8ab8 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T8.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callbac public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* c public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callb public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callbac public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback c public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback cal public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback cal public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callb public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback c public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T9.g.cs index 7457ee74..9f41c3e8 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable.IIterable/T9.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct PageIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callb public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callba public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback cal public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callbac public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback c public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback cal public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback cal public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* ca public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callb public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback c public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback c public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T1.g.cs index 3670bf1c..2840eee9 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T1.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T10.g.cs index b24dac42..38b86154 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T10.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T11.g.cs index 2c03c439..8099e2de 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T11.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T12.g.cs index 8bc8c36a..3dd27446 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T12.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T13.g.cs index abdd985c..591bb200 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T13.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T14.g.cs index 4de8dff0..66e860ae 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T14.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T15.g.cs index 59312020..7c3d5b83 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T15.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T16.g.cs index b0c9b096..301f9bb1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T16.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T2.g.cs index b08bab02..bc0e6145 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T2.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T3.g.cs index 8f81240c..453c0684 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T3.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T4.g.cs index fec43310..c77507f3 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T4.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T5.g.cs index dd421277..c865c1fa 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T5.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T6.g.cs index 9cba2b63..a105549b 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T6.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T7.g.cs index d5d877f4..09cd8514 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T7.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T8.g.cs index 22bb63b3..2493e347 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T8.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T9.g.cs index fa196c0a..bb67ab32 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/PageIterable/PageIterable/T9.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct PageIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _pageIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T1.g.cs index b5416bb6..cd80d439 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T1.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, void> callback) public void Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T10.g.cs index 11b7fc59..5bd7f477 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T10.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback c public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback ca public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback cal public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback c public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T11.g.cs index 1a97489f..5e42e7a1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T11.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T12.g.cs index cafc22e5..af7ca815 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T12.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T13.g.cs index 6e186ea0..3b6bea73 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T13.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T14.g.cs index 982679da..a7bbe9b1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T14.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T15.g.cs index cb6b2a94..7ad907e1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T15.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T16.g.cs index a547e437..a96d277f 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T16.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T2.g.cs index 8802eb34..98b0b48e 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T2.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, void> callback) public void Iter(delegate*, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T3.g.cs index 9f2fa957..ae5d6b86 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T3.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, void> callback public void Iter(delegate*, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T4.g.cs index 6fb0c86c..43bca8cb 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T4.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, voi public void Iter(delegate*, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, void> c public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* call public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* ca public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T5.g.cs index fc4dbae4..bb9f260c 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T5.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T6.g.cs index a791af85..81033690 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T6.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callba public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callbac public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callbac public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T7.g.cs index 360b56d0..4f4d1b98 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T7.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callba public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callb public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* call public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* c public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callbac public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback cal public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* ca public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T8.g.cs index 280faf0f..b5905a98 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T8.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callbac public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* c public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callb public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callbac public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback c public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback cal public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback cal public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callb public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback c public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T9.g.cs index 90864e97..0ea80fac 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query.IIterable/T9.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct Query public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callb public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callba public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback cal public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callbac public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback c public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback cal public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback cal public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* ca public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callb public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback c public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback c public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T1.g.cs index 80079f08..ba2c691f 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T1.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T10.g.cs index cf7cca17..5bd89fd0 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T10.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T11.g.cs index 83dacf62..440149d3 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T11.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T12.g.cs index 576fa80b..bf7582c9 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T12.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T13.g.cs index cbbfb8fc..421020bd 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T13.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T14.g.cs index bc388223..83189af5 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T14.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T15.g.cs index 7d48bd89..0ae9fa14 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T15.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T16.g.cs index a028f133..7adfc7e3 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T16.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T2.g.cs index f789c0a5..eb869e32 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T2.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T3.g.cs index 7c696eaf..d4274935 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T3.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T4.g.cs index 4ca3cac2..4ad36e0e 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T4.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T5.g.cs index 53c3e804..ec46a034 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T5.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T6.g.cs index 9c111d8d..29424c5d 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T6.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T7.g.cs index 5636b3cc..64f488b9 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T7.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T8.g.cs index 9b4d127f..38eb7e36 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T8.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T9.g.cs index 9a480e6e..6c4fc2d0 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/Query/Query/T9.g.cs @@ -199,6 +199,9 @@ public World RealWorld() // IIterableBase Interface public unsafe partial struct Query : IIterableBase { + /// + ref ecs_world_t* IIterableBase.World => ref Ecs.GetIterableWorld(ref _query); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T1.g.cs index 7e6746e0..32661668 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T1.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder public System Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback callback) public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* callback) public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCallback callback) public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCallback callback) public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerCallback callback) public System Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate*, void> callback) public System Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate*, void> callback) public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* callback) public System Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallback callback) public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRefCallback callback) public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefCallback callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* callback) public System Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerCallback callback) public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPointerCallback callback) public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPointerCallback callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T10.g.cs index 648dfc9c..1e299599 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T10.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback callba public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCallback public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCallback< public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerCallba public System Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate* Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate* Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallback Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRefCall public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefCallba public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerCallba public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPointer public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPointerCa public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T11.g.cs index 56455e9a..33d186fc 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T11.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback c public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCal public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCall public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerC public System Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate* Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate* Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallb public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRe public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefC public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerC public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPo public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPoin public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T12.g.cs index 559a4b80..66da096f 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T12.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallb public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFie public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpa public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPoi public System Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate* Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate* Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRef public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEnt public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIte public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPoi public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEnt public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIte public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T13.g.cs index 7d4d51f9..88a80c7d 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T13.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.Run public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegat public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.It public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.It public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.It public System Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delega public System Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delega public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delega public System Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.Ea public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.Ea public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.Ea public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delega public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delega public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delega public System Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.Ea public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.Ea public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.Ea public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delega public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delega public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T14.g.cs index 25dbee95..572e5e92 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T14.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ec public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(de public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(E public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(E public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(E public System Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(d public System Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(d public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(d public System Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(E public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(E public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(E public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(d public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(d public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(d public System Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(E public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(E public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(E public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(d public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(d public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T15.g.cs index 2a794ef0..88f9b4ed 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T15.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System R public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System R public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System I public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System I public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System I public System Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System I public System Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System I public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System I public System Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System E public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System E public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System E public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System E public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System E public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System E public System Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System E public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System E public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System E public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System E public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System E public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T16.g.cs index 8400ad4b..542666be 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T16.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T2.g.cs index c4d7e7a0..188881f4 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T2.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder public System Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback callback) public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* callback) public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCallback callback) public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCallback callback) public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerCallback callback) public System Iter(delegate*, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate*, Field, void> callback) public System Iter(delegate*, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate*, Span, void> callback) public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* callback) public System Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallback callback) public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRefCallback callback) public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefCallback callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* callback) public System Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerCallback callback) public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPointerCallback callback) public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPointerCallback callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T3.g.cs index 0369df7a..683a7c9e 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T3.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder public System Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback callback) public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* callback) public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCallback callback) public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCallback callback) public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerCallback callback) public System Iter(delegate*, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate*, Field, Field, public System Iter(delegate*, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate*, Span, Span, voi public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* callback) public System Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallback callback) public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRefCallback callback) public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefCallback callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* c public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerCallback callback) public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPointerCallback callbac public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPointerCallback callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T4.g.cs index 0201725c..b0228d13 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T4.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder public System Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback callback) public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* callback) public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCallback callbac public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCallback callback public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerCallback callb public System Iter(delegate*, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate*, Field, Field Iter(delegate*, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate*, Span, Span, public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* cal public System Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallback callback) public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRefCallback cal public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefCallback callb public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerCallback callb public System Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPointerCallback public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPointerCallback c public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* callback) public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* c public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T5.g.cs index d056d076..a0845164 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T5.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder public System Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback callback) public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* callback) public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCallback public System Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCallback public System Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerCallback Iter(delegate*, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate*, Field, Fie public System Iter(delegate*, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate*, Span, Span< public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallback c public System Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRefCallback Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerCallback Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPointerCallback Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPointerCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T6.g.cs index 2da6f8f5..231d28d5 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T6.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder public System Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback callback) public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* callback) public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCallback Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCallback Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerCallback Iter(delegate*, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate*, Field, public System Iter(delegate*, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate*, Span, S public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallback Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRefCallback Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerCallback Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPointerCallback Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPointerCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T7.g.cs index 95f673fc..f98ba009 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T7.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder public System Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback callback) public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* callback) public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCallback Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCallback Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerCallback Iter(delegate*, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate*, Field< public System Iter(delegate*, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate*, Span Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallback Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRefCallback Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerCallback Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPointerCallback Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPointerCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T8.g.cs index b9a6c7b0..b9da45c5 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T8.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder public System Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback callback) public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* callback public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCallback Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCallback Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerCallback Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate*, Fi public System Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate*, Spa public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallback Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRefCallback Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerCallback Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPointerCallback public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPointerCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T9.g.cs index 24823ed9..767947d7 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/SystemBuilder/SystemBuilder.NodeBuilder/T9.g.cs @@ -14,6 +14,7 @@ public unsafe partial struct SystemBuilder public System Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun(callback, Pointers.RunCallbackDelegate).Build(); } @@ -24,6 +25,7 @@ public System Run(Ecs.RunCallback callback) public System Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetRun((IntPtr)callback, Pointers.RunCallbackPointer).Build(); } @@ -34,6 +36,7 @@ public System Run(delegate* call public System Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterFieldCallbackDelegate).Build(); } @@ -44,6 +47,7 @@ public System Iter(Ecs.IterFieldCallback Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterSpanCallbackDelegate).Build(); } @@ -54,6 +58,7 @@ public System Iter(Ecs.IterSpanCallback Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback(callback, Pointers.IterPointerCallbackDelegate).Build(); } @@ -64,6 +69,7 @@ public System Iter(Ecs.IterPointerCallback Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterFieldCallbackPointer).Build(); } @@ -74,6 +80,7 @@ public System Iter(delegate* public System Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterSpanCallbackPointer).Build(); } @@ -84,6 +91,7 @@ public System Iter(delegate*, public System Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, false); return SetCallback((IntPtr)callback, Pointers.IterPointerCallbackPointer).Build(); } @@ -94,6 +102,7 @@ public System Iter(delegate* Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachRefCallbackDelegate).Build(); } @@ -104,6 +113,7 @@ public System Each(Ecs.EachRefCallback Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityRefCallbackDelegate).Build(); } @@ -114,6 +124,7 @@ public System Each(Ecs.EachEntityRefCallback public System Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterRefCallbackDelegate).Build(); } @@ -124,6 +135,7 @@ public System Each(Ecs.EachIterRefCallback Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachRefCallbackPointer).Build(); } @@ -134,6 +146,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityRefCallbackPointer).Build(); } @@ -144,6 +157,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterRefCallbackPointer).Build(); } @@ -154,6 +168,7 @@ public System Each(delegate* Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachPointerCallbackDelegate).Build(); } @@ -164,6 +179,7 @@ public System Each(Ecs.EachPointerCallback Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachEntityPointerCallbackDelegate).Build(); } @@ -174,6 +190,7 @@ public System Each(Ecs.EachEntityPointerCall public System Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback(callback, Pointers.EachIterPointerCallbackDelegate).Build(); } @@ -184,6 +201,7 @@ public System Each(Ecs.EachIterPointerCallba public System Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachPointerCallbackPointer).Build(); } @@ -194,6 +212,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachEntityPointerCallbackPointer).Build(); } @@ -204,6 +223,7 @@ public System Each(delegate* Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(World, true); return SetCallback((IntPtr)callback, Pointers.EachIterPointerCallbackPointer).Build(); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T0.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T0.g.cs index c0d9dd50..da9218c6 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T0.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T0.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper public static readonly int Tags = (Type.IsTag ? 1 << 0 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 1) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 1) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 1) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T1.g.cs index edadef01..51df41fd 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T1.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper public static readonly int Tags = (Type.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 2) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 2) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 2) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T10.g.cs index 6c20856b..6aae44e1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T10.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0) | (Type.IsTag ? 1 << 6 : 0) | (Type.IsTag ? 1 << 7 : 0) | (Type.IsTag ? 1 << 8 : 0) | (Type.IsTag ? 1 << 9 : 0) | (Type.IsTag ? 1 << 10 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 6 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 7 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 8 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 9 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 10 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 11) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 11) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 11) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 6 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 7 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 8 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 9 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 10 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T11.g.cs index 4cfcd380..7bf453f5 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T11.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0) | (Type.IsTag ? 1 << 6 : 0) | (Type.IsTag ? 1 << 7 : 0) | (Type.IsTag ? 1 << 8 : 0) | (Type.IsTag ? 1 << 9 : 0) | (Type.IsTag ? 1 << 10 : 0) | (Type.IsTag ? 1 << 11 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 6 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 7 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 8 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 9 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 10 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 11 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 12) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 12) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 12) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 6 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 7 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 8 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 9 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 10 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 11 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T12.g.cs index 1e04df60..5ee5a2d1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T12.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0) | (Type.IsTag ? 1 << 6 : 0) | (Type.IsTag ? 1 << 7 : 0) | (Type.IsTag ? 1 << 8 : 0) | (Type.IsTag ? 1 << 9 : 0) | (Type.IsTag ? 1 << 10 : 0) | (Type.IsTag ? 1 << 11 : 0) | (Type.IsTag ? 1 << 12 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 6 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 7 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 8 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 9 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 10 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 11 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 12 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 13) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 13) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 13) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 6 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 7 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 8 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 9 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 10 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 11 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 12 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T13.g.cs index c858281a..cfb8d469 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T13.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0) | (Type.IsTag ? 1 << 6 : 0) | (Type.IsTag ? 1 << 7 : 0) | (Type.IsTag ? 1 << 8 : 0) | (Type.IsTag ? 1 << 9 : 0) | (Type.IsTag ? 1 << 10 : 0) | (Type.IsTag ? 1 << 11 : 0) | (Type.IsTag ? 1 << 12 : 0) | (Type.IsTag ? 1 << 13 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 6 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 7 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 8 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 9 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 10 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 11 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 12 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 13 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 14) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 14) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 14) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 6 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 7 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 8 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 9 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 10 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 11 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 12 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 13 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T14.g.cs index 086337a8..b0776938 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T14.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0) | (Type.IsTag ? 1 << 6 : 0) | (Type.IsTag ? 1 << 7 : 0) | (Type.IsTag ? 1 << 8 : 0) | (Type.IsTag ? 1 << 9 : 0) | (Type.IsTag ? 1 << 10 : 0) | (Type.IsTag ? 1 << 11 : 0) | (Type.IsTag ? 1 << 12 : 0) | (Type.IsTag ? 1 << 13 : 0) | (Type.IsTag ? 1 << 14 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 6 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 7 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 8 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 9 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 10 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 11 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 12 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 13 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 14 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 15) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 15) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 15) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 6 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 7 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 8 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 9 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 10 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 11 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 12 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 13 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 14 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T15.g.cs index fe1f5575..98deb813 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T15.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0) | (Type.IsTag ? 1 << 6 : 0) | (Type.IsTag ? 1 << 7 : 0) | (Type.IsTag ? 1 << 8 : 0) | (Type.IsTag ? 1 << 9 : 0) | (Type.IsTag ? 1 << 10 : 0) | (Type.IsTag ? 1 << 11 : 0) | (Type.IsTag ? 1 << 12 : 0) | (Type.IsTag ? 1 << 13 : 0) | (Type.IsTag ? 1 << 14 : 0) | (Type.IsTag ? 1 << 15 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 6 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 7 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 8 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 9 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 10 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 11 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 12 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 13 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 14 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 15 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 16) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 16) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 16) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 6 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 7 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 8 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 9 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 10 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 11 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 12 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 13 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 14 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 15 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T2.g.cs index cf82d958..d8be6445 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T2.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper public static readonly int Tags = (Type.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 3) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 3) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 3) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T3.g.cs index 3d1411da..5651affa 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T3.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper public static readonly int Tags = (Type.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 4) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 4) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 4) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T4.g.cs index 778c2fcc..c13144a8 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T4.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper public static readonly int Tags = (Type.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 5) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 5) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 5) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T5.g.cs index 6b54764c..209649bb 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T5.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper public static readonly int Tags = (Type.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 6) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 6) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 6) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T6.g.cs index 408769cd..eb423a11 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T6.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper public static readonly int Tags = (Type.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0) | (Type.IsTag ? 1 << 6 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 6 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 7) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 7) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 7) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 6 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T7.g.cs index 3734d10e..cc617ca2 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T7.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper public static readonly int Tags = (Type.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0) | (Type.IsTag ? 1 << 6 : 0) | (Type.IsTag ? 1 << 7 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 6 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 7 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 8) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 8) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 8) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 6 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 7 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T8.g.cs index e888bc33..02fd1666 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T8.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper public static readonly int Tags = (Type.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0) | (Type.IsTag ? 1 << 6 : 0) | (Type.IsTag ? 1 << 7 : 0) | (Type.IsTag ? 1 << 8 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 6 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 7 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 8 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 9) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 9) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 9) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 6 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 7 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 8 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T9.g.cs index 02e309e1..7a7d4585 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/TypeHelper/T9.g.cs @@ -6,11 +6,14 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; +using Flecs.NET.Utilities; + +using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; [SuppressMessage("ReSharper", "StaticMemberInGenericType")] -internal static partial class TypeHelper +internal static unsafe partial class TypeHelper { private static string[]? _typeNames; public static string[] TypeNames => _typeNames ??= [ Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName, Type.FullName ]; @@ -18,17 +21,20 @@ internal static partial class TypeHelper public static readonly int Tags = (Type.IsTag ? 1 << 0 : 0) | (Type.IsTag ? 1 << 1 : 0) | (Type.IsTag ? 1 << 2 : 0) | (Type.IsTag ? 1 << 3 : 0) | (Type.IsTag ? 1 << 4 : 0) | (Type.IsTag ? 1 << 5 : 0) | (Type.IsTag ? 1 << 6 : 0) | (Type.IsTag ? 1 << 7 : 0) | (Type.IsTag ? 1 << 8 : 0) | (Type.IsTag ? 1 << 9 : 0); public static readonly int ReferenceTypes = (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 0 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 1 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 2 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 3 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 4 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 5 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 6 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 7 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 8 : 0) | (RuntimeHelpers.IsReferenceOrContainsReferences() ? 1 << 9 : 0); + private static string GetTypeListString(int fields) + { + return string.Join(", ", Enumerable.Range(0, 10) + .Where(i => (fields & (1 << i)) != 0) + .Select(i => TypeNames[i])); + } + [Conditional("DEBUG")] public static void AssertNoTags() { if (Tags == 0) return; - string tags = string.Join(", ", Enumerable.Range(0, 10) - .Where(i => (Tags & (1 << i)) != 0) - .Select(i => TypeNames[i])); - - Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {tags}"); + Ecs.Error($"Cannot use zero-sized structs as generic type arguments for this struct. Remove the following type arguments: {GetTypeListString(Tags)}"); } [Conditional("DEBUG")] @@ -37,10 +43,20 @@ public static void AssertReferenceTypes(bool allowReferenceTypes) if (allowReferenceTypes || ReferenceTypes == 0) return; - string referenceTypes = string.Join(", ", Enumerable.Range(0, 10) - .Where(i => (ReferenceTypes & (1 << i)) != 0) - .Select(i => TypeNames[i])); + Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {GetTypeListString(ReferenceTypes)}"); + } - Ecs.Error($"Cannot use managed types as generic type arguments for callback signatures that retrieve pointers or spans. Remove the following type arguments: {referenceTypes}"); + [Conditional("DEBUG")] + public static void AssertSparseTypes(ecs_world_t* world, bool allowSparseTypes) + { + if (allowSparseTypes) + return; + + int sparseTypes = (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 0 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 1 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 2 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 3 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 4 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 5 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 6 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 7 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 8 : 0) | (ecs_has_id(world, Type.Id(world), Ecs.Sparse) == Utils.True ? 1 << 9 : 0); + + if (sparseTypes == 0) + return; + + Ecs.Error($"Cannot use sparse components as generic type arguments for this struct when using .Iter() to iterate because sparse fields must be obtained with Iter.FieldAt(). Use .Each()/.Run() to iterate or remove the following types from the list: {GetTypeListString(sparseTypes)}"); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T1.g.cs index db2147f7..f2d34ed0 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T1.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, void> callback) public void Iter(delegate*, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T10.g.cs index d20d5d7a..f991fa2f 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T10.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback c public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback ca public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback cal public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback c public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T11.g.cs index 1122462a..78ebdc33 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T11.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T12.g.cs index bdfd3d4f..d4beb7d3 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T12.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T13.g.cs index bfb9c3e9..6c3359b9 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T13.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T14.g.cs index c2fe32cc..050e2a1a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T14.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T15.g.cs index 44d6211b..84de28a3 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T15.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T16.g.cs index 63c54651..7bb807f1 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T16.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T2.g.cs index cac9066e..931b6a30 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T2.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, void> callback) public void Iter(delegate*, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T3.g.cs index be966ad9..40876d8a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T3.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, void> callback public void Iter(delegate*, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, void> callback) public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T4.g.cs index 5503a077..c1201e9c 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T4.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, voi public void Iter(delegate*, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, void> c public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* call public void Each(Ecs.EachPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* ca public Entity Find(Ecs.FindPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T5.g.cs index 0f7642c6..8c8f6396 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T5.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T6.g.cs index b16c2e4f..bc412e71 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T6.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callba public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callback) public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callbac public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callbac public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T7.g.cs index b2381d1b..a131f109 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T7.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callback) public void Iter(delegate*, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callba public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callback) public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callback) public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callb public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callback) public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* call public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* c public Entity Find(Ecs.FindRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback callbac public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callback) public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback cal public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callback) public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* ca public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T8.g.cs index 1214e75f..73041392 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T8.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callback) public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callback) public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback callbac public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* c public void Each(Ecs.EachRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callback) public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback callb public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback callbac public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback c public void Each(Ecs.EachIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback cal public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* callbac public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callback) public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback cal public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback callb public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback c public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* callb public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T9.g.cs index 46cb4f3a..87046663 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable.IIterable/T9.g.cs @@ -13,6 +13,7 @@ public unsafe partial struct WorkerIterable public void Run(Ecs.RunCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -23,6 +24,7 @@ public void Run(Ecs.RunCallback callback) public void Run(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Run(ref this, callback); } @@ -33,6 +35,7 @@ public void Run(delegate* callback) public void Iter(Ecs.IterFieldCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -43,6 +46,7 @@ public void Iter(Ecs.IterFieldCallback callb public void Iter(Ecs.IterSpanCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -53,6 +57,7 @@ public void Iter(Ecs.IterSpanCallback callba public void Iter(Ecs.IterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -63,6 +68,7 @@ public void Iter(Ecs.IterPointerCallback cal public void Iter(delegate*, Field, Field, Field, Field, Field, Field, Field, Field, void> callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -73,6 +79,7 @@ public void Iter(delegate*, Field, Field, Field, Fie public void Iter(delegate*, Span, Span, Span, Span, Span, Span, Span, Span, void> callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -83,6 +90,7 @@ public void Iter(delegate*, Span, Span, Span, Span callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), false); Invoker.Iter(ref this, callback); } @@ -93,6 +101,7 @@ public void Iter(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -103,6 +112,7 @@ public void Each(Ecs.EachRefCallback callbac public void Each(Ecs.EachEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -113,6 +123,7 @@ public void Each(Ecs.EachEntityRefCallback c public void Each(Ecs.EachIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -123,6 +134,7 @@ public void Each(Ecs.EachIterRefCallback cal public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -133,6 +145,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -143,6 +156,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -153,6 +167,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -163,6 +178,7 @@ public void Each(Ecs.EachPointerCallback cal public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -173,6 +189,7 @@ public void Each(Ecs.EachEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -183,6 +200,7 @@ public void Each(Ecs.EachIterPointerCallback public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -193,6 +211,7 @@ public void Each(delegate* ca public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -203,6 +222,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); Invoker.Each(ref this, callback); } @@ -213,6 +233,7 @@ public void Each(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -223,6 +244,7 @@ public Entity Find(Ecs.FindRefCallback callb public Entity Find(Ecs.FindEntityRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -233,6 +255,7 @@ public Entity Find(Ecs.FindEntityRefCallback public Entity Find(Ecs.FindIterRefCallback callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -243,6 +266,7 @@ public Entity Find(Ecs.FindIterRefCallback c public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -253,6 +277,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -263,6 +288,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(true); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -273,6 +299,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -283,6 +310,7 @@ public Entity Find(Ecs.FindPointerCallback c public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -293,6 +321,7 @@ public Entity Find(Ecs.FindEntityPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -303,6 +332,7 @@ public Entity Find(Ecs.FindIterPointerCallback callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -313,6 +343,7 @@ public Entity Find(delegate* public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } @@ -323,6 +354,7 @@ public Entity Find(delegate* callback) { TypeHelper.AssertReferenceTypes(false); + TypeHelper.AssertSparseTypes(Ecs.GetIterableWorld(ref this), true); return Invoker.Find(ref this, callback); } } \ No newline at end of file diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T1.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T1.g.cs index 155ccd55..f7e90538 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T1.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T1.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T10.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T10.g.cs index 42dc5f39..a17dff08 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T10.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T10.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T11.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T11.g.cs index edd77bac..c1ba9880 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T11.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T11.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T12.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T12.g.cs index 8b288592..82cb8a78 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T12.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T12.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T13.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T13.g.cs index 81b44030..6b1cbb8b 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T13.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T13.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T14.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T14.g.cs index fb34d14d..1046e342 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T14.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T14.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T15.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T15.g.cs index e4f6bdd6..1531d98a 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T15.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T15.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T16.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T16.g.cs index eb43532a..27adf083 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T16.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T16.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T2.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T2.g.cs index 780c8f71..8a3a6011 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T2.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T2.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T3.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T3.g.cs index 160fbb60..a1f0cb71 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T3.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T3.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T4.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T4.g.cs index 31c33402..c41c52c4 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T4.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T4.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T5.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T5.g.cs index cf5501c1..4196b7d9 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T5.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T5.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T6.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T6.g.cs index df596c9a..21bbb8c9 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T6.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T6.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T7.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T7.g.cs index 42d8ac93..1e8b45dc 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T7.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T7.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T8.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T8.g.cs index d074787b..a55b54d7 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T8.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T8.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T9.g.cs b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T9.g.cs index 7fb3003d..db807850 100644 --- a/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T9.g.cs +++ b/src/Flecs.NET/Generated/Flecs.NET.Codegen/WorkerIterable/WorkerIterable/T9.g.cs @@ -63,6 +63,9 @@ public override int GetHashCode() // IIterableBase Interface public unsafe partial struct WorkerIterable : IIterableBase { + /// + public ref ecs_world_t* World => ref _workerIterable.World; + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public ecs_iter_t GetIter(ecs_world_t* world = null) diff --git a/src/Flecs.NET/Utilities/Utils.cs b/src/Flecs.NET/Utilities/Utils.cs index 80981b8e..8388daa1 100644 --- a/src/Flecs.NET/Utilities/Utils.cs +++ b/src/Flecs.NET/Utilities/Utils.cs @@ -42,47 +42,42 @@ public static bool Bool(byte value) } /// - /// Gets the next power of 2 for the provided number. + /// Checks if specific bit is set. /// - /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int NextPowOf2(int num) + public static bool IsBitSet(int value, int index) { - num--; - num |= num >> 1; - num |= num >> 2; - num |= num >> 4; - num |= num >> 8; - num |= num >> 16; - num++; - - return num; + return (value & (1 << index)) != 0; } /// - /// Tests if 2 readonly refs point to the same object. + /// Checks if specific bit is set. /// - /// - /// - /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool AreSameReadOnlyRefs(in T a, in T b) + public static bool IsBitSet(uint value, int index) { - return Unsafe.AreSame(ref Unsafe.AsRef(in a), ref Unsafe.AsRef(in b)); + return (value & (1 << index)) != 0; } /// - /// Tests if a readonly ref is null. + /// Gets the next power of 2 for the provided number. /// - /// - /// + /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsNullReadOnlyRef(in T obj) + public static int NextPowOf2(int num) { - return Unsafe.IsNullRef(ref Unsafe.AsRef(in obj)); + num--; + num |= num >> 1; + num |= num >> 2; + num |= num >> 4; + num |= num >> 8; + num |= num >> 16; + num++; + + return num; } /// @@ -106,4 +101,4 @@ public static void OsFree(void* data) { OsFree((IntPtr)data); } -} \ No newline at end of file +} diff --git a/submodules/flecs b/submodules/flecs index 1af6e06b..02c8c266 160000 --- a/submodules/flecs +++ b/submodules/flecs @@ -1 +1 @@ -Subproject commit 1af6e06b6b5a220c5ea061ae448bc77494d085e1 +Subproject commit 02c8c2666b22ccce5706c8f16efaf813704fe31e