diff --git a/src/Arch.SourceGen/Fundamentals/Get.cs b/src/Arch.SourceGen/Fundamentals/Get.cs index 6e0ea39..95b5d9d 100644 --- a/src/Arch.SourceGen/Fundamentals/Get.cs +++ b/src/Arch.SourceGen/Fundamentals/Get.cs @@ -149,12 +149,12 @@ public static StringBuilder AppendChunkIndexGet(this StringBuilder sb, int amoun { var generics = new StringBuilder().GenericWithoutBrackets(amount); var inParams = new StringBuilder().InsertGenericParams(amount); - var arrays = new StringBuilder().GetChunkArrays(amount); + var arrays = new StringBuilder().GetChunkFirstGenericElements(amount); var gets = new StringBuilder(); for (var index = 0; index <= amount; index++) { - gets.AppendLine($"ref var t{index}Component = ref t{index}Array[index];"); + gets.AppendLine($"ref var t{index}Component = ref Unsafe.Add(ref t{index}FirstElement, index);"); } var template = @@ -186,13 +186,13 @@ public static StringBuilder AppendChunkIndexGetRows(this StringBuilder sb, int a public static StringBuilder AppendChunkIndexGetRow(this StringBuilder sb, int amount) { var generics = new StringBuilder().GenericWithoutBrackets(amount); - var getArrays = new StringBuilder().GetChunkArrays(amount); + var getArrays = new StringBuilder().GetChunkFirstGenericElements(amount); var inParams = new StringBuilder().InsertGenericParams(amount); var gets = new StringBuilder(); for (var index = 0; index <= amount; index++) { - gets.AppendLine($"ref var t{index}Component = ref t{index}Array[index];"); + gets.AppendLine($"ref var t{index}Component = ref Unsafe.Add(ref t{index}FirstElement, index);"); } var template = @@ -203,7 +203,7 @@ public static StringBuilder AppendChunkIndexGetRow(this StringBuilder sb, int am { {{getArrays}} - ref var entity = ref Entities[index]; + ref var entity = ref Entity(index); {{gets}} return new EntityComponents<{{generics}}>(ref entity, {{inParams}}); diff --git a/src/Arch.SourceGen/Fundamentals/Set.cs b/src/Arch.SourceGen/Fundamentals/Set.cs index 0855962..c68dd45 100644 --- a/src/Arch.SourceGen/Fundamentals/Set.cs +++ b/src/Arch.SourceGen/Fundamentals/Set.cs @@ -16,12 +16,12 @@ public static StringBuilder AppendChunkIndexSet(this StringBuilder sb, int amoun { var generics = new StringBuilder().GenericWithoutBrackets(amount); var parameters = new StringBuilder().GenericInParams(amount); - var arrays = new StringBuilder().GetChunkArrays(amount); + var arrays = new StringBuilder().GetChunkFirstGenericElements(amount); var sets = new StringBuilder(); for (var index = 0; index <= amount; index++) { - sets.AppendLine($"t{index}Array[index] = t{index}Component;"); + sets.AppendLine($"Unsafe.Add(ref t{index}FirstElement, index) = t{index}Component;"); } var template = @@ -80,7 +80,7 @@ public static StringBuilder AppendArchetypeSetRange(this StringBuilder sb, int a { var generics = new StringBuilder().GenericWithoutBrackets(amount); var parameters = new StringBuilder().GenericInDefaultParams(amount,"ComponentValue"); - var getFirstElements = new StringBuilder().GetFirstGenericElements(amount); + var getFirstElements = new StringBuilder().GetChunkFirstGenericElements(amount); var getComponents = new StringBuilder().GetGenericComponents(amount); var assignComponents = new StringBuilder(); diff --git a/src/Arch.SourceGen/Queries/InlineQuery.cs b/src/Arch.SourceGen/Queries/InlineQuery.cs index 7227074..fcb588c 100644 --- a/src/Arch.SourceGen/Queries/InlineQuery.cs +++ b/src/Arch.SourceGen/Queries/InlineQuery.cs @@ -81,7 +81,7 @@ public static StringBuilder AppendQueryInterfaceMethods(this StringBuilder build for (var index = 0; index <= amount; index++) { var generics = new StringBuilder().GenericWithoutBrackets(index); - var getFirstElement = new StringBuilder().GetFirstGenericElements(index); + var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(index); var getComponents = new StringBuilder().GetGenericComponents(index); var insertParams = new StringBuilder().InsertGenericParams(index); @@ -111,7 +111,7 @@ public static StringBuilder AppendQueryInterfaceMethods(this StringBuilder build for (var index = 0; index <= amount; index++) { var generics = new StringBuilder().GenericWithoutBrackets(index); - var getFirstElement = new StringBuilder().GetFirstGenericElements(index); + var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(index); var getComponents = new StringBuilder().GetGenericComponents(index); var insertParams = new StringBuilder().InsertGenericParams(index); @@ -148,7 +148,7 @@ public static StringBuilder AppendEntityQueryInterfaceMethods(this StringBuilder for (var index = 0; index <= amount; index++) { var generics = new StringBuilder().GenericWithoutBrackets(index); - var getFirstElement = new StringBuilder().GetFirstGenericElements(index); + var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(index); var getComponents = new StringBuilder().GetGenericComponents(index); var insertParams = new StringBuilder().InsertGenericParams(index); @@ -181,7 +181,7 @@ public static StringBuilder AppendEntityQueryInterfaceMethods(this StringBuilder for (var index = 0; index <= amount; index++) { var generics = new StringBuilder().GenericWithoutBrackets(index); - var getFirstElement = new StringBuilder().GetFirstGenericElements(index); + var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(index); var getComponents = new StringBuilder().GetGenericComponents(index); var insertParams = new StringBuilder().InsertGenericParams(index); diff --git a/src/Arch.SourceGen/Queries/Job.cs b/src/Arch.SourceGen/Queries/Job.cs index f48d1c2..bcd430a 100644 --- a/src/Arch.SourceGen/Queries/Job.cs +++ b/src/Arch.SourceGen/Queries/Job.cs @@ -13,7 +13,7 @@ public static void AppendForEachJobs(this StringBuilder sb, int amount) public static void AppendForEachJob(this StringBuilder sb, int amount) { var generics = new StringBuilder().GenericWithoutBrackets(amount); - var getFirstElement = new StringBuilder().GetFirstGenericElements(amount); + var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount); var getComponents = new StringBuilder().GetGenericComponents(amount); var insertParams = new StringBuilder().InsertGenericParams(amount); @@ -52,7 +52,7 @@ public static void AppendEntityForEachJobs(this StringBuilder sb, int amount) public static void AppendEntityForEachJob(this StringBuilder sb, int amount) { var generics = new StringBuilder().GenericWithoutBrackets(amount); - var getFirstElement = new StringBuilder().GetFirstGenericElements(amount); + var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount); var getComponents = new StringBuilder().GetGenericComponents(amount); var insertParams = new StringBuilder().InsertGenericParams(amount); @@ -93,7 +93,7 @@ public static void AppendIForEachJobs(this StringBuilder sb, int amount) public static void AppendIForEachJob(this StringBuilder sb, int amount) { var generics = new StringBuilder().GenericWithoutBrackets(amount); - var getFirstElement = new StringBuilder().GetFirstGenericElements(amount); + var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount); var getComponents = new StringBuilder().GetGenericComponents(amount); var insertParams = new StringBuilder().InsertGenericParams(amount); @@ -132,7 +132,7 @@ public static void AppendIForEachWithEntityJobs(this StringBuilder sb, int amoun public static void AppendIForEachWithEntityJob(this StringBuilder sb, int amount) { var generics = new StringBuilder().GenericWithoutBrackets(amount); - var getFirstElement = new StringBuilder().GetFirstGenericElements(amount); + var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount); var getComponents = new StringBuilder().GetGenericComponents(amount); var insertParams = new StringBuilder().InsertGenericParams(amount); diff --git a/src/Arch.SourceGen/Queries/Query.cs b/src/Arch.SourceGen/Queries/Query.cs index d77cff0..b02d8da 100644 --- a/src/Arch.SourceGen/Queries/Query.cs +++ b/src/Arch.SourceGen/Queries/Query.cs @@ -63,7 +63,7 @@ public static StringBuilder AppendQueryMethods(this StringBuilder sb, int amount public static StringBuilder AppendQueryMethod(this StringBuilder sb, int amount) { var generics = new StringBuilder().GenericWithoutBrackets(amount); - var getFirstElement = new StringBuilder().GetFirstGenericElements(amount); + var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount); var getComponents = new StringBuilder().GetGenericComponents(amount); var insertParams = new StringBuilder().InsertGenericParams(amount); @@ -103,7 +103,7 @@ public static StringBuilder AppendEntityQueryMethods(this StringBuilder sb, int public static StringBuilder AppendEntityQueryMethod(this StringBuilder sb, int amount) { var generics = new StringBuilder().GenericWithoutBrackets(amount); - var getFirstElement = new StringBuilder().GetFirstGenericElements(amount); + var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount); var getComponents = new StringBuilder().GetGenericComponents(amount); var insertParams = new StringBuilder().InsertGenericParams(amount); diff --git a/src/Arch.SourceGen/Queries/SetWithQueryDescription.cs b/src/Arch.SourceGen/Queries/SetWithQueryDescription.cs index c021dab..270e783 100644 --- a/src/Arch.SourceGen/Queries/SetWithQueryDescription.cs +++ b/src/Arch.SourceGen/Queries/SetWithQueryDescription.cs @@ -29,7 +29,7 @@ public static StringBuilder AppendSetWithQueryDescriptions(this StringBuilder sb public static void AppendSetWithQueryDescription(this StringBuilder sb, int amount) { var generics = new StringBuilder().GenericWithoutBrackets(amount); - var getFirsts = new StringBuilder().GetFirstGenericElements(amount); + var getFirsts = new StringBuilder().GetChunkFirstGenericElements(amount); var getComponents = new StringBuilder().GetGenericComponents(amount); var parameters = new StringBuilder().GenericInDefaultParams(amount,"ComponentValue"); diff --git a/src/Arch.SourceGen/StringBuilderExtensions.cs b/src/Arch.SourceGen/StringBuilderExtensions.cs index fae466f..e509444 100644 --- a/src/Arch.SourceGen/StringBuilderExtensions.cs +++ b/src/Arch.SourceGen/StringBuilderExtensions.cs @@ -48,7 +48,7 @@ public static StringBuilder GenericWithoutBrackets(this StringBuilder sb, int am /// /// /// - public static StringBuilder GetFirstGenericElements(this StringBuilder sb, int amount) + public static StringBuilder GetChunkFirstGenericElements(this StringBuilder sb, int amount) { for (var localIndex = 0; localIndex <= amount; localIndex++) {