I am not completely sure how "systems" are supposed to be used in some
specific cases.
However you need them to be used. There is no single correct way to build a component-based entity system (not all of them even include the concept of a "system"), and even among implementations that use similar terminology, not all the details are alike.
You need to focus on building the system that accomplishes the goals you have set for your project.
How would one implement AI and how would the component look like? I am
especially confused when it comes to actions. Could actions be stored
in the components as objects?
AI in games is about the modeling of behavior more than anything else. Interfaces that implement AI on a per-entity basis (entity system or not) are typically called "agents" or "actors," and typically contain code or data to control behavior of an individual creature/person/NPC/object/et cetera in the game. With that in mind, a common way to put AI into a component-based entity system is to have BehaviorComponent
(or AgentComponent
or ActorComponent
, et cetera) which are associated with entities. Such a component implements an entire class of behavior for an entity and generally you don't attach multiple (although you could). For example, you might have an FollowPlayerBehavior
component or an AttacksFromCover
component.
In many games, "AI" typically just means executing behavior scripts, so often you won't even see dedicated AI systems or components since such behavior is normally just handled by more general scripting components that allow designers to attach arbitrary Lua (or whatnot) scripts to entities.
I would not recommend an approach where you implement individual actions an entity can take as components and shove a bunch of them on to an entity, as that is too fine-grained and doesn't afford you the ability to easily order the actions without enforcing an overly-rigid update order on your entity component system. It also makes branching decisions difficult, and implies you're going to do a lot of adding and removing of components at runtime which isn't always very common (and thus not always very efficient).
As always, the specifics of what goes into an "AI component" are going to depend heavily on your game itself: what it needs from AI, how your AI works in absence of the component system (the component system, remember, is a high-level object composition system and something like AI, rendering, physics should all be usable without also requiring the use of the component system; keeping that in mind will help you design better systems that work in isolation and help avoid the design paralysis that so often comes with building component systems for some reason).