I've got a background in C++ but completely new to game dev, Unreal, and ECS.
Recently, I learned about ECS and fell in love with the resulting project structure and theoretical reduction of spaghetti code that could arise as a game project grows. However, Unreal (or most other mainstream engines) have limited or no ECS systems ready to go. As a result, I decided to try to implement what I like to call a Pseudo-ECS on my own within an Unreal project that lets Unreal handle basics like rendering and physics, and the Pseudo-ECS will handle all gameplay logic.
It's similar to a true ECS system in terms of separation of data and logic, however it does not follow the ECS memory layout, entity id lookups, or even querying for that matter. Here's how it's set up:
All components/systems are derived from these 2
ActorComponent classes and live in their respective folders:
ECS_Component is added/removed from an actor in the world, that actor is stored in a global queue for the next frame to process.
Every tick, the global queue is processed against a list of registered
ECS_Systems and then cleared. Essentially,
ApplySystems will be called on every actor that had a change to the
ECS_Components that were applied to it.
ApplySystems checks the required
ECS_Components for each
ECS_System (using a set of 4 int64 bitflags & bitmasks, supporting up to 255 components) and if the actor has those components, then that
ECS_System is added/removed from it.
The function is a bit too big to post here. Basically, it loops through all the components on the actor and generates a bitflagged set of int64's. Then it loops through every system in the game and checks via bitmask to see if the actor should use the system.
The result; all system logic only runs on actors that have the required components. When a component is added/removed, the actor gets updated to ensure it has the right systems at all times. And this works! I successfully created basic health, hunger, and follow systems with this.
Here's the thing... obviously, I would be missing out on any performance gains from a true ECS system, however performance is not what drew me to ECS in the first place. That being said, I don't want this system to be a hindrance to the games performance either.
My question is, do you think this Pseudo-ECS system is worth using even without a true ECS memory layout or querying system? I really have no frame of reference to know this...