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

Emit event when scene is ready #9115

Closed
Shatur opened this issue Jul 11, 2023 · 10 comments · Fixed by #9313
Closed

Emit event when scene is ready #9115

Shatur opened this issue Jul 11, 2023 · 10 comments · Fixed by #9313
Labels
A-Scenes Serialized ECS data stored on the disk C-Enhancement A new feature

Comments

@Shatur
Copy link
Contributor

Shatur commented Jul 11, 2023

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

Scenes spawned with delay and in order to check if scene is spawned we use SceneSpawner::instance_is_ready. But it's not very convenient because you can't actually react on spawning.

What solution would you like?

Introduce ReadyScene component that inserted after scene spawning.

What alternative(s) have you considered?

Events, but marker component is more flexible because we also be able to filter loaded scenes in queries.

@Shatur Shatur added C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels Jul 11, 2023
@Olle-Lukowski
Copy link
Contributor

Hey, I want to get into contributing to Bevy and I think this would be a good place for me to start, so if I can try working on this that would be awesome!

@Olle-Lukowski
Copy link
Contributor

Should this component be applied for both types of spawning? (non-dynamic and dynamic) Or just one of them? @Shatur

@Shatur
Copy link
Contributor Author

Shatur commented Jul 11, 2023

Should this component be applied for both types of spawning?

Yes, I think so.

@james7132
Copy link
Member

Could we make this an event instead of a component? Seems more appropriate than a persistent component that forces more archetype fragmentation.

@Shatur
Copy link
Contributor Author

Shatur commented Jul 11, 2023

Could we make this an event instead of a component?

This is what I outlined in "alternatives". But I think "valid scene" is a persistent state. And you will be able to iterate over all valid scenes + easier to get components of such scene via query.

@mockersf
Copy link
Member

it's possible to invalidate a scene by changing the handle, so it would make handling an additional component needs to be kept in sync with that. I would much prefer an event as a one time thing

@mockersf mockersf added A-Scenes Serialized ECS data stored on the disk and removed S-Needs-Triage This issue needs to be labelled labels Jul 11, 2023
@Shatur
Copy link
Contributor Author

Shatur commented Jul 11, 2023

Yes, I thought that we will keep the component in sync...

But I see your point, let's go with event then.

@Shatur
Copy link
Contributor Author

Shatur commented Jul 11, 2023

But I see your point, let's go with event then.

On second thought, how we will check if scene was "just loaded" to emit the event? With component approach we can use Without for iteration.

@Shatur Shatur changed the title Mark valid scenes with component Mark ready scenes with component Jul 11, 2023
@Shatur
Copy link
Contributor Author

Shatur commented Jul 12, 2023

On second thought, how we will check if scene was "just loaded" to emit the event?

I have an idea, we can emit the event when we insert the scene handle to spawned map.
@Olle-Lukowski if you planning to work on it, please switch your PR to events.

@Shatur Shatur changed the title Mark ready scenes with component Emit event when scene is ready Jul 29, 2023
@Shatur
Copy link
Contributor Author

Shatur commented Jul 31, 2023

Opened #9313.

github-merge-queue bot pushed a commit that referenced this issue Aug 15, 2023
# Objective

Closes #9115, replaces #9117.

## Solution

Emit event when scene is ready.

---

## Changelog

### Added

- `SceneInstanceReady` event when scene becomes ready.
Shatur added a commit to projectharmonia/bevy that referenced this issue Aug 19, 2023
# Objective

Closes bevyengine#9115, replaces bevyengine#9117.

## Solution

Emit event when scene is ready.

---

## Changelog

### Added

- `SceneInstanceReady` event when scene becomes ready.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Scenes Serialized ECS data stored on the disk C-Enhancement A new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants