TL;DR: Should I have distinct components such as PlayerController and CameraController that would act as a “brain” this would tie/couple systems to an entity. Or make systems that update components and systems that act on the updated components this way systems aren't (or shouldn't) be tied to a specific entity.
So I'm a little confused on how to make systems in ECS it feels like I'm trying to make systems based on the entity rather than the components which leaves me with some systems being niche I guess? In my game engine project when it comes to input I have a global input manager (a singleton?) which is not part of the ECS then I created a PlayerController and CameraController which uses the input manager like this:
class CameraController : public ISystem {
public:
void Update(float timestep) override {
// Mouse Input
if (gInputManager.IsMouseButtonDown(SDL_BUTTON_RIGHT)) {
}
// Keyboard Input
if (gInputManager.IsKeyDown(SDLK_w)) {
}
if (gInputManager.IsKeyDown(SDLK_s)) {
}
}
};
class PlayerController : public ISystem {
public:
void Update(float timestep) override {
// Keyboard Input
if (gInputManager.IsKeyDown(SDLK_w)) {
}
if (gInputManager.IsKeyDown(SDLK_s)) {
}
// Jump
if (gInputManager.IsKeyDown(SDLK_SPACE)) {
}
// Some ability
if (gInputManager.IsKeyDown(SDLK_e)) {
}
}
};
So, these systems are only useful to a single type of entity, and I feel like that might be the opposite of what ECS is trying to accomplish? Something I've seen frequently is to have some sort of input component I don't actually know how this would work, but if I had to take a stab the idea seems to be you'd have one system that updates your input component and then any entity that needs input uses that component and then I'd have like a mover system that uses the input component to move the entity so now instead of having a system targeting a specific entity like the camera or player I have two general purpose systems that can handle movement for any entity that uses input. This raises a few questions though like being able to look around with the camera or the player being able to activate abilities these are specific or handled differently by some entities which I think is why I went with my original code.
So, I'm curious of both methods mentioned are valid or if one is more typical than the other?