Currently SystemBase code like this:
Entities.ForEach( ( Entity ent, ref MapUnitColor mapUnitColor, in ApplyColorBasedUponUsability colouring ) =>
{
mapUnitColor.Value = HasComponent<IsUsable>( ent ) ? colorBasedUponUsability.UsableColor : colorBasedUponUsability.NotUsableColor;
}).Run();
Results in code like this:
[MethodImpl(MethodImplOptions.NoInlining)]
public void IterateEntities(ref ArchetypeChunk chunk, [NoAlias] ref LambdaParameterValueProviders.Runtimes runtimes)
{
int count = chunk.Count;
for (int i = 0; i < count; i++)
{
OriginalLambdaBody(runtimes.runtime_ent.For(i), ref runtimes.runtime_color.For(i), in runtimes.runtime_colouring.For(i));
}
}
private void OriginalLambdaBody(Entity ent, ref MapUnitColor mapUnitColor, in ApplyColorBasedUponUsability colorBasedUponUsability)
{
mapUnitColor.Value = (_ComponentDataFromEntity_IsUsable_0.HasComponent(ent) ? colorBasedUponUsability.UsableColor : colorBasedUponUsability.NotUsableColor);
}
Currently everytime we call the OriginalLamdaBody we check if the entity we iterate upon has the component.
Wouldn’t it be possible to do a chunk based lookup and branch upon that inside the IterateEntities method?
Is the performance gain we would get from that negligible?
Or am i just missing something?