leudz / shipyard

Entity Component System focused on usability and flexibility.
Other
755 stars 46 forks source link

What's the usage of require_before/require_after? #195

Open snskshn opened 7 months ago

snskshn commented 7 months ago

As I understood, things like as follows:

// case1. without require_before A B.after_all(A) // A -> B C.after_all(B) // A -> B -> C

// case2. with require_before A B.require_after(A).after_all(A) // A -> B C.require_after(B).after_all(B) // A -> B -> C

Then, require_after is useless?? what's the case of require*'s usage?

leudz commented 5 months ago

after_all/before_all change systems ordering but don't check if the system is present in the workload. require_after/require_before don't change systems ordering but assert that a system is present in the workload.


So let's say you have this instead:

A
C.after_all(B)

There is no B so C is placed automatically, after_all(B) is ignored.

With this:

A
C.require_before(B).after_all(B)

You get an error saying that C expected a system B but there was none in the workload.

System(C) is missing some systems before: [System(B)]