Skip to content

System's executing order based component that the system read and writes #2379

@ghost

Description

Now System's execute order based label, but why not base component that the system read and writes by default?

Like Unity: https://docs.unity3d.com/Packages/[email protected]/manual/ecs_job_dependencies.html

By Example

The following code output is:

> system_2
> system_1

but with the system_2 with SystemParam Res, and system_1 with ResMut;

now may I run system_1 before system_2 runing by default without labeling system?

If the anser is not, and can you tell me that the difficult of implementation, or any other design concideration ?

#[test]
    fn test_system() {
        fn system_1(
            value: ResMut<bool>,
        ) {
            println!("system_1");
        }

        fn system_2(
            value: Res<bool>,
        ) {
            println!("system_2");
        }

        let mut world = World::default();
        world.insert_resource(false);
        
        let mut schedule = Schedule::default();
        let mut update = SystemStage::parallel();
        update.add_system(system_1.system());
        update.add_system(system_2.system());
        
        schedule.add_stage("update", update);
        
        schedule.run(&mut world);
    }

To my untrained eye, can I implement it by adding some derived macro inditate that SystemParameter dependency, which used in the system initialize ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions