I'm currently writing a generic engine for my incoming games. I have developed few games already but never with the same "base" and my code was/is quite a mess. The idea was to create an engine that I could use for any type of games.
I have read papers about entity/components managers. Some are using what they call nodes, systems etc... I thought it was a bit confusing, especially the node concept. I plan to not use nodes, and my question essentially is: "Is this a good engine concept"? And if it is not, what improvements could I make?
First, all elements in my game are entities. The player is an entity, any tile of the map or whatever is an entity. An entity (in my engine) is a basic class with a position, and a list of components. In my mind, all "features", "behaviors", etc, must be implemented through components. The entity class will also have an update and a render method. The entity holds an unique special component that is a component that implements an interface 'Renderable' and will handle the rendering of the entity, an entity that does not need to be rendered will not have a render component.
That was for the entity, now about component. Currently in my engine a component is something that brings something to the entity. For example, if I want my entity to be controllable via keyboard or whatever, I will add a component that handles this to my entity. And during the engine update process, the entity manager will update all its entities and each entity will update all its components (or at least the components that need to be updated).
class KeyboardControllComponent extends AbstractComponent implements Updatable {
@override
public void update() {
//do the input handling here
}
Basically this component will call another one (a movement component) that will actually apply the movement to the entity.
Also, I have implemented what I call a 'dispatcher' to my engine. It allows all elements to the game (everything in my game extends a GameElement class) to dispatch or listen for events. For example, if the hero walks on a specific thing (a trap for example), the component in charge of the hero entity movement/collision will fire an event to all game elements that are actually listening for that kind of events. I will take the example of an interrupter, the hero 'collide' this interrupter, the interrupter component in charge of collision will then fire a event to the entity that represents a door somewhere and open it.
Is this a good concept?
Finally, all game elements are handled by managers. EntityManager, DispatcherManager, SceneManager, etc...
Let me know what you think of my approach. I have not added actual code using the engine to not overload the post but if you want to see it, no problem.