Assuming we inherit the new implementation SystemBase, what would be the replacement for?
PostUpdateCommands.AddBuffer
&
PostUpdateCommands.SetComponent
Solution: Create A Job.WithCode to shcedule your task (rather than entity command buffer )
Add the buffer the the entity via the EntityManager, Add Component of the typeof you desire.
Job.WithCode(() =>
{
EntityManager.AddBuffer(ent);
//Component type is implicitly Read Write.
EntityManager.AddComponent(ent, typeof(ComponentType));
}).Schedule();
The actual solution to replicate the behaviour is to simply create the buffer yourself.
var PostUpdateCommands = new EntityCommandBuffer(Allocator.TempJob);
PostUpdateCommands.AddBuffer
PostUpdateCommands.SetComponent
PostUpdateCommands.PlayBack(EntityManager);
PostUpdateCommands.Dispose();
Assuming I’m running in the default World, is there not a more effective way to get a handle on an EntityCommandBuffer? As creating a new one would also create a new synch point as well correct? I guess my question is if there’s an ECB instantiated anywhere already in the architecture?
I don’t imagine I should create this in an Entity.ForEach()
Yes it will create a sync point, but that is exactly what PostUpdateCommands did and I was simply replicating the behaviour (EntityManager).
If you want to avoid sync points you need to use a buffer system to defer the sync point till later.