SanderMertens / flecs

A fast entity component system (ECS) for C & C++
https://www.flecs.dev
MIT License
5.64k stars 411 forks source link

Add overloads for flecs::entity and depends_on to allow scoped enums with an underlying type of entity_t. #1158

Closed RoyAwesome closed 3 months ago

RoyAwesome commented 3 months ago

I have some enums like:

 enum class engine : flecs::entity_t
 {
     main_window = EcsFirstUserEntityId,
     input,
     renderer,
     scripting,
     MAX,
 };

which allows me to just add entity ids in sequence for hardcoded entities. However, none of the flecs functions accept passing these enums as entity_t. I have to cast to the underlying type in my code.

So, I added some functions to accept enums like this so that I can just use these enums as I want.

//he::entities::pipeline is an enum with underlying type of flecs::entity_t
 world.entity(he::entities::pipeline::on_render_start).add(flecs::Phase).depends_on(he::entities::pipeline::on_window_start);

I only grabbed a few functions I'm currently using. If this PR is accepted, I will probably add more as I go through.

RoyAwesome commented 3 months ago

closed because #1151 is way better than this