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

Make WorldId Hash and SparseSetIndex #7124

Closed
recatek opened this issue Jan 7, 2023 · 0 comments
Closed

Make WorldId Hash and SparseSetIndex #7124

recatek opened this issue Jan 7, 2023 · 0 comments
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@recatek
Copy link
Contributor

recatek commented Jan 7, 2023

What problem does this solve or what need does it fill?

Currently WorldId can't be hashed in HashMap or used as a key in a SparseSet within bevy. This makes it challenging to branch behavior based on specific worlds (e.g. doing things differently for different SubApps). WorldId just wraps a usize so this should be safe to do.

What solution would you like?

Implement/derive Hash and SparseSetIndex for World.

What alternative(s) have you considered?

Worlds could be semi-uniquely identified through other means, like having a unique resource, but adding utility to the world's ID seems like the most straightforward choice.

Additional context

This would be particularly useful for generalizing cross-app extract functions. This came up while I was trying to make a extract function manager between a parent and multiple SubApp worlds, like so:

SparseSet<WorldId, Vec<Box<Fn(&mut World, &mut World)>>>
@recatek recatek added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jan 7, 2023
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jan 8, 2023
bors bot pushed a commit that referenced this issue Jan 9, 2023
# Objective

- Fixes #7124

## Solution

- Add Hash Derive on `WorldId`
- Add `SparseSetIndex` impl
@bors bors bot closed this as completed in 0e9f80e Jan 9, 2023
james7132 pushed a commit to james7132/bevy that referenced this issue Jan 21, 2023
# Objective

- Fixes bevyengine#7124

## Solution

- Add Hash Derive on `WorldId`
- Add `SparseSetIndex` impl
alradish pushed a commit to alradish/bevy that referenced this issue Jan 22, 2023
# Objective

- Fixes bevyengine#7124

## Solution

- Add Hash Derive on `WorldId`
- Add `SparseSetIndex` impl
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- Fixes bevyengine#7124

## Solution

- Add Hash Derive on `WorldId`
- Add `SparseSetIndex` impl
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 targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants