So I've been doing a lot of research into game engines, and Entity Component System (ECS) seems to be the most flexible and extendable design to use.
Just to summarize, in ECS the basic idea is that you have Entities which are just containers for Components, and different Components correspond to different functionality, but they only store data. So for example, in a tower defense game, you could have a tower entity which has a moveable component, but all the component really stores would be the towers current direction and velocity.
The actual logic of moving the tower is controlled in a System. What a System does is it iterates through all the entities that have specific components, and modifies them accordingly. So you would have a Movement System which would only look at the Movable Entities (it has a moveable component), and update the data accordingly.
So all this makes sense to me in terms of how to design a Game Object that stores all the info about a Game. My question is how would you incorporate custom user defined rules into this model? Because what I have is a game engine, it needs to be able to handle specific user defined rules which may vary from Game to Game, or even from Level to Level within a Game.
For example, let's say I want a rule saying that I want all towers to move, except when it's within a certain range of an enemy. Where would this logic reside? If it resides in the Movement system, that would me that I would need to create a new movement system for each game which is not how game engines are supposed to work right? The whole idea is that you feed it any game and the systems can handle it. Would I need a separate "Rules" system?
Please let me know if I can clarify anything. Thanks for the help!