Skip to content

Command Buffer: delay removal of entity / component #18

@DavidPeicho

Description

@DavidPeicho

It looks like the community still needs deferred removal. I think a good way to go for that, would be to implement CommandBuffer in the same way other ECS work.

Command

Commands contain semantic about how to apply the its state onto the world. We would need command such as:

  • RemoveComponentCommand
  • RemoveEntityCommand

Later on, this can go even further with other types of commands.

CommandBuffer

CommandBuffer's contain a set of command to apply. For instance, an entire group of system could register command in a single buffer that will later be applied.

The key here is to let the user choose when to apply the commands. We could create default basic command buffers:

  • Per-System command buffer: applied after a system is done running
  • Per-Group command buffer: applied after a system group is done running
  • Per-World execution command buffer: applied after all groups and all systems are done running

Internals

Using command buffers would make the implementation simple. There is no need for the internals to track what is removed and when to remove it.

Drawbacks

No deferred removal possible outside of systems

With an implementation like that, it seems impossible for someone to remove in a deferred fashion a component / entity. For me, it doesn't make sense to remove something deferred when not executing the world, but maybe some people have use cases for that?

EDIT

Turns out #21 raised a really good point. If deferred removal is done only when ticking, then resources might leak (exemple with WebGL object allocated in systems). Command buffers should then be exposed to users outside of systems as well! The good thing is that it shouldn't be hard to implement

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions