ECS - Steelhead-Games/CharmQuarkEngine-wiki GitHub Wiki
If you want to create a component that can be serialized, deserialized and added to the reflection system
- You have to create a class inherited from
EntitySystem::EntityComponent
. There are also predefined classesFloatComponent
,Vector3FloatComponent
andVector4FloatComponent
that already contain predefined Serialization methods. TheEntitySystem::EntityComponent
class contains the API for the engine to work with; this way, it can be connected to all the necessary systems. - You have to register the component in the
GameFramework::RegisterComponents()
method. Like this
EntitySystem::EntityManager::RegisterComponent<Velocity>(m_World);
- For your component, define methods
Serialize
,Deserialize
andRegisterComponent
. An example of what you have to do about them you can find in theclass ENTITY_SYSTEM_API Position final : public cqe::EntitySystem::Vector3FloatComponent
class.
Just use struct
. That's it
struct Velocity
{
float x, y, z;
}
and then use it with the entities. Don't overcomplicate your code and don't do redundant work.