After finishing one internal project and now working on the next project (non-game) we found some common problems with content and entities in v1.0 and v1.1, especially when things change over time and the data is not longer compatible (happened mostly in UI controls). Instead of trying to patch things over and over again we redesigned the content system earlier this month to be more data driven. Thanks to that we had some ideas to improve entities as well to be more data driven. Most simple entities have really good performance in the Delta Engine and were highly optimized for the use cases we had (Sprites, Lines, 3D models, LogoApp), but once you start adding more logic, things got slow quickly. Obviously in each case we could optimize it again, but code is not getting prettier and doing it on the build service side is too much work for our now much smaller team.
Starting with v1.2 entity is just an empty sealed class, you cannot derive it or do any OOP, it just has some optional tags to find things later if needed and some entities can have children (like Buttons nested in a Panel). You can also add components to describe what an entity is about, they are not stored in the entity and can even be reused by multiple entities. Examples are Position2D, Color, Material, Rotation, PhysicsBody, Trigger, Action, etc. Entities can also be just templates, which means no logic or rendering is executed for them, but the data is all there to create new alive instances from it. And you can turn a entity invisible, which turns off the attached renderers while keeping their components and render data alive. That is pretty much it, all of it is data driven, which means we can easily safe it in the editor, there is no functionality in any of the entities or components, it is all just data (in fact we enforce it, if you put anything but public fields in components, the system will detect it and throw an exception).
To make things simple in code as well plus support old v1.1 code as well as we can, an EntityCreator class is available. Obviously not having Update or Draw methods or OOP in entities is going to break all kinds of things inside the engine and some of the games utilizing this. For example Line2D, Sprite or Model are not longer entities, but derive from EntityCreator, which internally just creates a entity and adds all the required components. This way the code stays mostly compatible, is easy to use for newbies not knowing or wanting to use or extend entities, but you are totally free to create your own entities and customize it as much as you want. This is pretty much the only way to create anything in the Delta Engine anyway (as opposed to other engines where you have a huge list of existing classes you can use that do not use the same system as you). Unreal Engine 4 Blueprint system is also an inspiration on what could be done, but we do not plan to do anything as complex and complete, we still like writing code in C#, much faster that way (both in writing and execution speed).
Here are two quick pictures I drew in the last 2 hours while explaining the new system. Maybe next time we should record it so users can benefit from our training as well :)
First whiteboard image is just a bunch of ideas from during the week (going into a more data driven "MVC" way, was changed back to "Systems" and "Renderers" for clarity later):
The next whiteboard image is about the new entity component system in all its glory with data locality explained, components and examples plus how the editor works:
If you want to know more and read additional articles about entity systems check out our wiki page on this topic.