Skip to content

Commit

Permalink
fix variadic oversights
Browse files Browse the repository at this point in the history
  • Loading branch information
DESKTOP-O6U9TBJ\Lilith committed Nov 1, 2023
1 parent af7bda7 commit e66f22b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Arch/Core/Variadics/EntityExtensions.Variadics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public static bool Has<T0, T1>(this Entity entity)
/// <inheritdoc cref="Set{T}"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Variadic(nameof(T1), 2)]
public static void Set<T0, T1>(this Entity entity, T0 component__T0, T1 component__T1)
public static void Set<T0, T1>(this Entity entity, in T0 component__T0, in T1 component__T1)
{
var world = World.Worlds[entity.WorldId];
// [Variadic: CopyArgs(component)]
world.Set(entity, component__T0, component__T1);
world.Set(entity, in component__T0, in component__T1);
}

/// <inheritdoc cref="Get{T}"/>
Expand All @@ -41,7 +41,7 @@ public static void Add<T0, T1>(this Entity entity, in T0 component__T0, in T1 co
{
var world = World.Worlds[entity.WorldId];
// [Variadic: CopyArgs(component)]
world.Add(entity, component__T0, component__T1);
world.Add(entity, in component__T0, in component__T1);
}

/// <inheritdoc cref="Remove{T}"/>
Expand Down
3 changes: 1 addition & 2 deletions src/Arch/Core/Variadics/Jobs.Variadics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public struct ForEachWithEntityJob<T0> : IChunkJob
public readonly void Execute(int index, ref Chunk chunk)
{
ref var entityFirstElement = ref chunk.Entity(0);
var chunkSize = chunk.Size;
// [Variadic: CopyLines]
ref var firstElement__T0 = ref chunk.GetFirst<T0>();

for (var entityIndex = chunkSize - 1; entityIndex >= 0; --entityIndex)
foreach (var entityIndex in chunk)
{
var entity = Unsafe.Add(ref entityFirstElement, entityIndex);
// [Variadic: CopyLines]
Expand Down
5 changes: 3 additions & 2 deletions src/Arch/Core/Variadics/World.Variadics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,9 @@ public void Add<T0, T1>(in QueryDescription queryDescription, in T0 component__T
var lastSlot = newArchetype.LastSlot;
// [Variadic: CopyArgs(component)]
newArchetype.SetRange(in lastSlot, in newArchetypeLastSlot, in component__T0, in component__T1);
// [Variadic: CopyLines]
OnComponentAdded<T0>(archetype);
// [Variadic: CopyLines]
OnComponentAdded<T1>(archetype);
archetype.Clear();
}
}
Expand Down Expand Up @@ -570,7 +571,7 @@ public void Remove<T0, T1>(in QueryDescription queryDescription)
var spanBitSet = new SpanBitSet(bitSet.AsSpan(stack));
spanBitSet.ClearBit(Component<T0>.ComponentType.Id);
// [Variadic: CopyLines]
spanBitSet.ClearBit(Component<T0>.ComponentType.Id);
spanBitSet.ClearBit(Component<T1>.ComponentType.Id);

// Get or create new archetype.
if (!TryGetArchetype(spanBitSet.GetHashCode(), out var newArchetype))
Expand Down

0 comments on commit e66f22b

Please sign in to comment.