I have been reading a lot about different design patterns, their pros, cons, main usage etc. However, I like to experiment and try to invent my own ways of the implementations (even if they are not the best). Now I am facing a problem with my Entity component system implementation.
Despite of the pros of this pattern I want to do some of the things in my own way, for example:
1.) Components are wrapped into bigger interfaces for data manipulation. In most of the cases i read that ECS components must contain only data and the systems are their main manipulators. In my system I intend to use a wrapper classes for the components
Little example: Lets say we want to have a Sprite component, that represents the visual component of each entity in game. I wrapped it inside the RenderableEntity class that can be a component of an entity and has additional functions and variables.
2.) I don´t use a system for every type of component.
Again an example from game engine : We have a CollidableEntity, that is put in some spatial data structure and doing its collision checks, but for RenderableEntity there is no system that manages it (I assume that we are in 2D now). Reason? I want the user to have the power of rendering the sprites of each entities, because of specific order or using different batches.
3.) Entities can have more than 1 component of the same type and no bitsets are used for checking if is the system interested in given entity. The components are assigned to systems at their creation via the data type.
Little code:
template<class DataType>
DataType* createComponent(GameEntity* mainEntity)
{
//Create it via default constructor
DataType* component = new DataType();
//Add it to the back of the component vector
mainEntity->_entityComponents.emplace_back(component);
//Assign it to system
ECS::assignToSystem<T>(component);
//Return it to access its functions
return component;
}
The assignToSystem function does following : checks if is the given data type in our map and if not, it adds the component to the system and from now is the system the maintainer of the component. Also the gamesystems are attached to given data types via a function and it looks like this :
class ColliderSystem:public ECS::System
{
void assignSystem() override
{
ECS::assignSystemToComponent<CollidableEntity>(this);
}
};
Can you tell me if its a good idea to experiment with given patterns and try to do things your own way? Especially I care about this because want to use this approach in my graduation work and wonder if it will be a problem if I "break rules" of some patterns. Also , what do you think about my "changes", are there any cons? Thanks.