-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Component/system structs get generated with a static constexpr field called id which means that we cannot use id as an ecsact field. This is a fairly common field name. It's completely reasonable for a user to write something like this:
component Player { i32 id; }
To workaround this users must give a more unique name such as this:
component Player { i32 player_id; }
This is an annoying workaround and may become more of an issue if we introduce more static constexpr fields. I think we can solve this in 2 different ways.
1) all static constexpr have prefix or suffix _
In ecsact you're not allowed to have prefix or suffix _ for your fields so this may work. However, we may relax this rule in the future.
2) use a traits struct
Instead of having a static constexpr fields we could use template specialized structs (AKA C++ traits)
template<>
struct ecsact::component_traits<ExampleComponent> {
static constexpr ecsact_component_id id = /* codegen value */;
};This has the advantage of not conflicting with any user code, but makes access to the components ID in C++ code look like this:
-C::id
+ecsact::component_traits<C>::id