CommandBuffer

You have lots of plans, lots of orders for your subordinates but you can't carry them all out at once? How cool would it be if someone could do it for you?

It's often like this... we have a lot planned, but we can't do it all at once, we have to work through it piece by piece. The same applies to your world and entities, of course... and we have something for that here! The CommandBuffer is exactly for that. You can give it your commands, it saves them and executes them at a later time. Practical, especially for multithreading and if you want to postpone changes until later.

// Our dwarf
var dwarf = world.Create(new Dwarf(), new Position(), new Velocity());

// Buffering actions on entities to play them back later
var commandBuffer = new CommandBuffer();

commandBuffer.Set(dwarf, new Position(10,10);

// Buffering a whole entity

Actions on entities can therefore be postponed and executed at a later time. This is sometimes more effective than executing them directly, all actions are thread-safe from theCommandBuffer and can also be executed in ParallelQuerys.

And now we can record changes and play them back at any time, that's cool, isn't it?

Last updated