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

Added a hook in 0.14 and it breaks the order of my commands #14581

Closed
ethereumdegen opened this issue Aug 2, 2024 · 4 comments
Closed

Added a hook in 0.14 and it breaks the order of my commands #14581

ethereumdegen opened this issue Aug 2, 2024 · 4 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@ethereumdegen
Copy link
Contributor

Bevy version

0.14

impl Component for InteractionAssertedComponent {
   const STORAGE_TYPE: StorageType = StorageType::Table;

   fn register_component_hooks(hooks: &mut ComponentHooks) {
       // Whenever this component is removed, or an entity with
       // this component is despawned...
       hooks.on_remove(|mut world, targeted_entity, _component_id|{
               
               //THESE TWO LINES BEING ADDED BREAKS COMMAND ORDERING
          //  let asserted_component = world.get::<InteractionAssertedComponent>(targeted_entity)  ; 
          //  let source = asserted_component.map( |s|  s.source.clone()).flatten() ; //drop the borrow of world ..
          // ----------


           let source = None ;
           
           let target = targeted_entity;


           let asserted = false;

           let Some(mut interaction_asserted_event_writer) = world.get_resource_mut::<Events<InteractionAssertedEvent>>() 
           else {return};

              info!("assert hook  remove");

           interaction_asserted_event_writer.send(
               InteractionAssertedEvent {
                   source,
                   target,
                   asserted


               }
           );
           //handle_interactable_assertion(&mut world, source, targeted_entity, false);


       });

I have proven that those two lines of code, when added to that hook, break the ordering constraints of commands elsewhere in my bevy codebase. This means that when those two lines of code are commented out , my commands which i define in order A, B actually execute in the next frame in the order B, A which ends up causing a fatal error in my code which i can not rectify without a massive massive massive rewrite.

It is true that commands are supposed to run in the order declared right?

Something bad is happening w this hook.

@ethereumdegen ethereumdegen added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Aug 2, 2024
@ethereumdegen
Copy link
Contributor Author

I noticed that the hook PR did make modifications to CommandQueue.rs and other command related files so i wonder if it introduced something bad like this

#10839

@hymm
Copy link
Contributor

hymm commented Aug 2, 2024

What are A and B here? Are they systems?

@ethereumdegen
Copy link
Contributor Author

ethereumdegen commented Aug 2, 2024

No, they are commands like command.entity(e).spawn and .despawn_recursive

And they inserted in the command queue in the same system (meaning they SHOULD be run in order that they are declared. But that hook makes them run out of order somehow )

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed S-Needs-Triage This issue needs to be labelled labels Aug 2, 2024
@ethereumdegen
Copy link
Contributor Author

Okay sorry nope i found the issue. When source was some and asserted was false, it was causing my other game code to do a " double level load " causing my issue. This isnt an issue with bevy but something very complex on my end.

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-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

No branches or pull requests

3 participants