I have a simple culling system that needs to add DisableRendering to Entities that fall out of range, and remove it from Entities coming into range.
I think the boilerplate-to-code ratio exceeds 10 lines to 1 line. This is untenable. What other patterns or suggestions to you have? (this is not about optimization of the distance check yet, but I would like to optimize the structural change to happen only for those where it is needed.)
Complications: SOME of the entities have an associated UIEntity, but not all.
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var cameraState = SystemAPI.GetSingleton<CameraState>();
var ecb = GetEntityCommandBuffer(ref state).AsParallelWriter();
var show = new ShowEntitiesInCameraRange
{
_ecb = ecb,
cameraPosition = cameraState.position
};
show.ScheduleParallel();
var show2 = new ShowPipsInCameraRange
{
_ecb = ecb,
cameraPosition = cameraState.position
};
show2.ScheduleParallel();
var hide = new HideEntitiesOutsideCameraRange
{
_ecb = ecb,
cameraPosition = cameraState.position
};
hide.ScheduleParallel();
var hide2 = new HidePipsOutsideCameraRange
{
_ecb = ecb,
cameraPosition = cameraState.position
};
hide2.ScheduleParallel();
}