r/roguelikedev • u/spire-winder • 3h ago
Questions about ECS
TL;DR: Is it okay to let components have logic in an ECS to prevent system bloat?
Hello! I am currently creating a traditional roguelike engine in Python, using an ECS framework.
Currently I am trying to figure out how I want to handle game logic. I know the traditional approach is to have Systems handle logic. So for example there is a MovementSystem that listens for the MoveIntent component to be added to an Entity, then queries the World to check for collision, and finally updates that Entity's Position.
But I expect that myself and others using my engine will want to create many unique components for all sort of reasons. For example, if a user wants to have many different types of armor/damage prevention, they would need a DamageSystem (or multiple Systems, each handling a different stage of damage calculation), that would need to check every single equipped Entity for each of these individual components.
I am worried that this could have performance impacts, especially because the System needs to run and check all of the relevant entities, even if none of those entities end up having the component.
I understand that separating logic and data is an important part of an ECS, but wouldn't it make more sense to support individual components to listen for events and act themselves? So each variety of Armor component would listen to DamageIntents themselves instead of having a DamageSystem search for Armor components.
Thanks for taking the time to read this!
