Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove auto reset from Command Buffer PlayBack() method #205

Closed
skelitheprogrammer opened this issue Feb 29, 2024 · 5 comments
Closed

Remove auto reset from Command Buffer PlayBack() method #205

skelitheprogrammer opened this issue Feb 29, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@skelitheprogrammer
Copy link
Contributor

skelitheprogrammer commented Feb 29, 2024

After PlayBack() method command buffer auto dispose everything user recorded. Its great for cases where you prevent NullRefs.

But, what if, it would be optional choice? What about only creational command buffers?
When I was looking at #21 I tried to code sample solution, using command buffer. With this reset, user have to re-record the same steps, to do the same thing

For example:

  • Create Command buffer
  • Record Entity Creation
  • Set Components with values
  • PlayBack()
This will be repeated N times, while it should only be  `PlayBack()` N times
- Record Entity Creation
- Set Components with values
- PlayBack()
@skelitheprogrammer skelitheprogrammer changed the title Remove auto dispose from Command Buffer Remove auto reset from Command Buffer PlayBack() method Feb 29, 2024
@genaray genaray added the enhancement New feature or request label Mar 3, 2024
@genaray
Copy link
Owner

genaray commented Mar 3, 2024

So you mean that it would be a usefull feature to record certain entities once and play them back on a regular basis? ^^

@skelitheprogrammer
Copy link
Contributor Author

Yes. I thought it was designed something like:

  • Register commands;
  • Use PlayBack() how much you need;
  • Dispose when needed;
For example that's how I use it right now with next code snippet:
// 1. Configure Archetype
// 2. Override Configure method to set up component data, using buffer
// 3. Use Init to execute creation

    public abstract class EntityTemplate
    {
        private readonly CommandBuffer _buffer;
        protected abstract ComponentType[] Template { get; }

        protected EntityTemplate(World world)
        {
            _buffer = new CommandBuffer(world);
        }

        protected abstract void Configure(CommandBuffer buffer, in Entity entity);

        public Entity Init()
        {
            Entity entity = _buffer.Create(Template);
            Configure(_buffer, entity);
            _buffer.Playback();
            return entity;
        }
    }

In the Init() method, I have to re-register commands to create the same entity type, because after PlayBack(), all registered commands are gone.

Does that makes sense? :D

@genaray
Copy link
Owner

genaray commented Mar 6, 2024

Yes. I thought it was designed something like:

  • Register commands;
  • Use PlayBack() how much you need;
  • Dispose when needed;

Kinda, well it makes sense to add an way to permit the reset each playback ^^
Its also linked to : #202 which does not link the commandbuffer directly to the world.

I would really appreciate a pr for this :)

Oh and there's also : #21 which solves the problem differently

@skelitheprogrammer
Copy link
Contributor Author

Yes. I thought it was designed something like:

  • Register commands;
  • Use PlayBack() how much you need;
  • Dispose when needed;

Kinda, well it makes sense to add an way to permit the reset each playback ^^ Its also linked to : #202 which does not link the commandbuffer directly to the world.

I would really appreciate a pr for this :)

Oh and there's also : #21 which solves the problem differently

Sure, I will make a pr when I will get my hands on.

@genaray
Copy link
Owner

genaray commented Mar 13, 2024

Was introduced in 5f5b058

@genaray genaray closed this as completed Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants