bilowik / bevy_despawn_particles

The Unlicense
2 stars 0 forks source link

Max particles config, track when particles were created and despawn the oldest ones if exceeding max config #8

Closed bilowik closed 1 year ago

bilowik commented 1 year ago

Will need two resources, the config, and the Resource to hold the current Count of existing particles.

But how do we keep the count of DespawnParticles? Do we just use a RO query and use len()? Would we even need the second Resource at that point?

bilowik commented 1 year ago

The resource should be a queue of Entitys that is updated in a system utilizing Added<DespawnParticle> query.

For now, it would probably be more efficient to just access and modify that from within the main system since it is the only place (currently) that these particles are created, but for bullet-proof future-proofing, I think a second system is worth the potentially less-than-optimal performance. I think it's most likely a completely negligible performance change.

bilowik commented 1 year ago

Downside to having a separate system tho, is that the resource that stores the particles may excessively grow under short-term huge loads and will retain all that allocated memory. If we handle it within the main system, it would not only be more efficient but it would also avoid over-allocating.

We may want to reduce it's allocated size in some cases on some kind of occasional interval if we stick with the separate system.

bilowik commented 1 year ago

Merged #20