Skip to content

Commit

Permalink
netstandard2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
andreakarasho committed Feb 10, 2024
1 parent 92e4438 commit bb7d3e2
Show file tree
Hide file tree
Showing 10 changed files with 699 additions and 184 deletions.
20 changes: 9 additions & 11 deletions src/Archetype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public ref T GetReference<T>(int column) where T : struct
{
EcsAssert.Assert(column >= 0 && column < Components!.Length);
ref var array = ref Unsafe.As<Array, T[]>(ref Components![column]);
#if NET
return ref MemoryMarshal.GetArrayDataReference(array);
#else
return ref array[0];
#endif
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -89,7 +93,7 @@ ComponentComparer comparer
internal Span<ArchetypeChunk> Chunks => _chunks.AsSpan(0, (_count + CHUNK_THRESHOLD - 1) / CHUNK_THRESHOLD);

[SkipLocalsInit]
public ref ArchetypeChunk GetChunk(int index)
internal ref ArchetypeChunk GetChunk(int index)
{
if (index >= _chunks.Length)
Array.Resize(ref _chunks, _chunks.Length * 2);
Expand Down Expand Up @@ -266,11 +270,7 @@ private void InsertVertex(Archetype newNode)

if (nodeTypeLen < newTypeLen - 1)
{
#if NET5_0_OR_GREATER
foreach (ref var edge in CollectionsMarshal.AsSpan(_edgesRight))
#else
foreach (var edge in _edgesRight)
#endif
foreach (ref var edge in CollectionsMarshal.AsSpan(_edgesRight))
{
edge.Archetype.InsertVertex(newNode);
}
Expand Down Expand Up @@ -346,16 +346,14 @@ public void Print()
static void PrintRec(Archetype root, int depth, int rootComponent)
{
Console.WriteLine(
"{0}Parent [{1}] common ID: {2}",
"{0}- Parent [{1}] common ID: {2}",
new string('\t', depth),
string.Join(", ", root.Components.Select(s => s.ID)),
string.Join(", ", root.Components.Select(s => Lookup.GetArray(s.ID, 0).ToString() )),

Check warning on line 351 in src/Archetype.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 351 in src/Archetype.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
rootComponent
);

if (root._edgesRight.Count > 0)
Console.WriteLine("{0}Children: ", new string('\t', depth));

//Console.WriteLine("{0}[{1}] |{2}| - Table [{3}]", new string('.', depth), string.Join(", ", root.ComponentInfo.Select(s => s.ID)), rootComponent, string.Join(", ", root.Table.Components.Select(s => s.ID)));
Console.WriteLine("{0} Children: ", new string('\t', depth));

foreach (ref readonly var edge in CollectionsMarshal.AsSpan(root._edgesRight))
{
Expand Down
Loading

0 comments on commit bb7d3e2

Please sign in to comment.