tomara-x / quartz

visual programming and dsp playground
https://codeberg.org/tomara-x/quartz
Apache License 2.0
36 stars 2 forks source link

:e scene is despawned before its children are loaded #123

Closed tomara-x closed 3 months ago

tomara-x commented 3 months ago

because now we despawn any scene, it's weird that it doesn't finish getting the children out first.. but i think that's caused by the children being spawned via a command in the loader

for (entity, scene, instance) in &mut scene_to_spawn {
        let new_instance = scene_spawner.spawn_as_child(scene.clone(), entity);
        if let Some(mut old_instance) = instance {
            scene_spawner.despawn_instance(**old_instance);
            *old_instance = SceneInstance(new_instance);
        } else {
            commands.entity(entity).insert(SceneInstance(new_instance));

still so weird, like, it inserts the sceneInstance after, so why would it have it before the children?

also do we need to do this like this? can't we spawn them a different way?

done a temporary fix 9ed2df876d5d431dd6, but it needs research

tomara-x commented 3 months ago

oh! the scene spawner!

so spawn_as_child will get called when scene_spawner_system is called (figure out when that is)

okay, it's in one "SpawnScene" schedule.. (pretty sure it's somewhere between update and last, that's why switching command_parser to PreUpdate worked, cause this had time to actually spawn) it is between Update and PostUpdate, but why did the command_parser running in pre had an effect on that?

but inserting the SceneInstance component on the other had is a normal command which is gonna happen the next time apply_deferred is called i think that's what's happening here

Ah! running the parser in Post (not pre) and so the command.. i have no clue! this is the opposite of what should work, but it works for some reason...

tomara-x commented 3 months ago

and why is this not an issue when spawning in paste_scene

tomara-x commented 3 months ago

instance_is_ready i need this!

tomara-x commented 3 months ago

scenespawner is so cute!! :heart_eyes:

tomara-x commented 3 months ago

for science! okay i'm fuggin sleeby!

tomara-x commented 3 months ago

can't use despawn_instance, apparently somehow it can still find the children? it's not a normal parent-child relationship