-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
206 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<#@ template language="C#" #> | ||
<#@ output extension=".cs" #> | ||
<#@ import namespace="System.Text" #> | ||
<#@ include file="Helpers.ttinclude" #> | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using CommunityToolkit.HighPerformance; | ||
using Arch.Core.Utils; | ||
|
||
namespace Arch.Core; | ||
|
||
public partial struct Chunk | ||
{ | ||
|
||
<# | ||
for (var index = 1; index < Amount; index++) | ||
{ | ||
var generics = AppendGenerics(index); | ||
|
||
var addEvents = new StringBuilder(); | ||
for (var i = 0; i < index; i++) | ||
addEvents.AppendLine($"OnComponentAdded<T{i}>(entity);"); | ||
|
||
var outs = new StringBuilder(); | ||
for (var i = 0; i < index; i++) | ||
outs.Append($"out T{i}[] t{i}Array,"); | ||
outs.Length--; | ||
|
||
var indexes = new StringBuilder(); | ||
for (var i = 0; i < index; i++) | ||
indexes.Append($"out var t{i}Index,"); | ||
indexes.Length--; | ||
|
||
var assignComponents = new StringBuilder(); | ||
for (var i = 0; i < index; i++) | ||
assignComponents.AppendLine($"t{i}Array = Unsafe.As<T{i}[]>(Unsafe.Add(ref arrays, t{i}Index));"); | ||
|
||
#> | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
[Pure] | ||
public void GetArray<<#= generics #>>(<#= outs #>) | ||
{ | ||
Index<<#= generics #>>(<#= indexes #>); | ||
ref var arrays = ref Components.DangerousGetReference(); | ||
<#= assignComponents #> | ||
} | ||
<# | ||
} | ||
#> | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<#@ template language="C#" #> | ||
<#@ output extension=".cs" #> | ||
<#@ import namespace="System.Text" #> | ||
<#@ include file="Helpers.ttinclude" #> | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using CommunityToolkit.HighPerformance; | ||
using Arch.Core.Utils; | ||
|
||
namespace Arch.Core; | ||
|
||
public partial struct Chunk | ||
{ | ||
|
||
<# | ||
for (var index = 1; index < Amount; index++) | ||
{ | ||
var generics = AppendGenerics(index); | ||
|
||
var arrays = new StringBuilder(); | ||
for (var i = 0; i <= index; i++) | ||
arrays.Append($"out var t{i}Array,"); | ||
arrays.Length--; | ||
|
||
var insertParams = new StringBuilder(); | ||
for (var i = 0; i <= index; i++) | ||
insertParams.Append($"ref t{i}Array.DangerousGetReference(),"); | ||
insertParams.Length--; | ||
|
||
#> | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
[Pure] | ||
public Components<<#= generics #>> GetFirst<<#= generics #>>() | ||
{ | ||
GetArray<<#= generics #>>(<#= arrays #>); | ||
return new Components<<#= generics #>>(<#= insertParams #>); | ||
} | ||
|
||
<# | ||
} | ||
#> | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<#@ template language="C#" #> | ||
<#@ output extension=".cs" #> | ||
<#@ import namespace="System.Text" #> | ||
<#@ include file="Helpers.ttinclude" #> | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using CommunityToolkit.HighPerformance; | ||
using Arch.Core.Utils; | ||
|
||
namespace Arch.Core; | ||
|
||
public partial struct Chunk | ||
{ | ||
<# | ||
for (var index = 1; index < Amount; index++) | ||
{ | ||
var generics = AppendGenerics(index); | ||
|
||
var outs = new StringBuilder(); | ||
for (var i = 0; i <= index; i++) | ||
outs.Append($"out Span<T{i}> t{i}Span,"); | ||
outs.Length--; | ||
|
||
var arrays = new StringBuilder(); | ||
for (var i = 0; i <= index; i++) | ||
arrays.Append($"out var t{i}Array,"); | ||
arrays.Length--; | ||
|
||
var assignComponents = new StringBuilder(); | ||
for (var i = 0; i <= index; i++) | ||
assignComponents.AppendLine($"t{i}Span = new Span<T{i}>(t{i}Array);"); | ||
|
||
#> | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
[Pure] | ||
public void GetSpan<<#= generics #>>(<#= outs #>) | ||
{ | ||
GetArray<<#= generics #>>(<#= arrays #>); | ||
<#= assignComponents #> | ||
} | ||
|
||
<# | ||
} | ||
#> | ||
} | ||
|
||
|
Oops, something went wrong.