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

Add EntityMap::clear #9291

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

Shatur
Copy link
Contributor

@Shatur Shatur commented Jul 27, 2023

Objective

If you use EntityMap to map entities over network (https://github.com/lifescapegame/bevy_replicon) you need to reset it sometimes, but keep allocated memory for reuse.

Solution


Changelog

Added

  • EntityMap::clear.

@Selene-Amanita Selene-Amanita added A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Jul 30, 2023
@mockersf
Copy link
Member

instead of adding all methods of HashMap to EntityMap, would it make more sense to impl Deref to HashMap?

@Shatur
Copy link
Contributor Author

Shatur commented Jul 30, 2023

It will require adding DerefMut, but I guess it does makes sense.
Will convenient methods like get by value override DerefMut methods? Should we keep them?

@Shatur
Copy link
Contributor Author

Shatur commented Jul 30, 2023

@mockersf what if we move world_scope to EntityMapper and just use plain HashMap everywhere?
If I understand correctly, EntityMap was created for better error handling, but we no longer have error handling after EntityMapper.

@alice-i-cecile
Copy link
Member

@Shatur this code is fine (and well-motivated!), but the questions raised above are sensible. What's your preferred way to proceed:

  1. Merge this PR as is, and split out the follow-up into a new issue / PR?
  2. Close this PR, and just move directly to the final solution.

I think my preference is for 1, but I'll defer to you here.

@Shatur
Copy link
Contributor Author

Shatur commented Jul 31, 2023

I would go with 1, it's a very small change.
And I will open a follow-up issue to discuss EntityMap.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jul 31, 2023
Merged via the queue into bevyengine:main with commit c6a1bf0 Jul 31, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants