Skip to content

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

Closed
@ethereumdegen

Description

@ethereumdegen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions