So, I started working on abilities. By abilities, I mean magic and spells and whatnot. To be precise, an ability is any way the an entity can change the scene or the game world.
Unsurprisingly, my abilities mostly create other entities that do stuff. For example, an ability create a entity that does damage when it collides with another entity. Baby stuff, right?
My engine uses a Entity-Component System. I sacrifice type safety for flexibility. Here’s the problem. Any concrete ability details relies on certain components. Someone, me, can easily remove necessary components. My code crashes and burns.
I could just prevent access to the entity model and only allow changes through some mutators. The problem with this is that my ECS completely loses its purpose. I might as well created classes for every single entity and allow access.
I had the brilliant idea to remove all specifics (projectiles, aoe, etc) and define an ability as a series of events with a specific entry point for running (when the ability is casted and using an optional target). This way, I don’t need to worry about relying on anything because I do not use anything. All I do is start the event. This is an especially good idea because it more faithful to what it happening, i.e. an ability creates a projectile and not an ability is a projectile.
I just wonder if this is too much abstraction. It comes dangerously close to programming with objects, particularly when it comes to modifying entities. Creating an entity can be done with one event but modifying is trickier because there are hundreds of different ways to modify an entity. I am, for sure, not making a event for every mutator.