Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::ecs::System Class Referenceabstract

Base class for all ECS systems. More...

#include <System.hpp>

Inheritance diagram for esengine::ecs::System:

Public Member Functions

virtual ~System ()=default
 Virtual destructor for proper cleanup.
virtual void init (Registry &registry)
 Called once when the system is added to a group.
virtual void update (World &world)=0
 Called every frame to execute system logic.
virtual void shutdown (Registry &registry)
 Called once when the system is removed.
void setEnabled (bool enabled)
 Enables or disables the system.
bool isEnabled () const
 Checks if the system is enabled.
void setPriority (i32 priority)
 Sets the system's execution priority.
i32 getPriority () const
 Gets the system's execution priority.

Protected Attributes

bool enabled_ = true
 Whether the system is enabled.
i32 priority_ = 0
 Execution priority (lower = earlier).

Detailed Description

Base class for all ECS systems.

Systems contain the logic that operates on entities with specific component configurations. Derive from this class and override update() to implement game logic.

class MovementSystem : public System {
public:
void update(World& world) override {
world.registry.each<Transform, Velocity>(
[&](Entity e, Transform& t, Velocity& v) {
t.position += v.linear * world.deltaTime;
});
}
};
// Usage:
systemGroup.createSystem<MovementSystem>();
Base class for all ECS systems.
Definition System.hpp:59
virtual void update(World &world)=0
Called every frame to execute system logic.
Entity identifier with packed index + generation.
Definition Types.hpp:135
Context passed to every System::update call.
Definition World.hpp:40
Unified transform component.
Definition Transform.hpp:45
Velocity component for simple kinematic motion.
Definition Velocity.hpp:41

Definition at line 59 of file System.hpp.

Constructor & Destructor Documentation

◆ ~System()

virtual esengine::ecs::System::~System ( )
virtualdefault

Virtual destructor for proper cleanup.

Member Function Documentation

◆ getPriority()

i32 esengine::ecs::System::getPriority ( ) const
inline

Gets the system's execution priority.

Returns
The priority value

Definition at line 125 of file System.hpp.

References priority_.

◆ init()

virtual void esengine::ecs::System::init ( Registry & registry)
inlinevirtual

Called once when the system is added to a group.

Parameters
registryReference to the ECS registry

Override to perform one-time initialization such as caching component pools or loading resources.

Reimplemented in esengine::ecs::TransformSystem.

Definition at line 71 of file System.hpp.

◆ isEnabled()

bool esengine::ecs::System::isEnabled ( ) const
inline

Checks if the system is enabled.

Returns
True if enabled

Definition at line 106 of file System.hpp.

References enabled_.

◆ setEnabled()

void esengine::ecs::System::setEnabled ( bool enabled)
inline

Enables or disables the system.

Parameters
enabledTrue to enable, false to disable

Disabled systems are skipped during update().

Definition at line 100 of file System.hpp.

References enabled_.

◆ setPriority()

void esengine::ecs::System::setPriority ( i32 priority)
inline

Sets the system's execution priority.

Parameters
priorityLower values execute first

Systems in a SystemGroup are sorted by priority. Default priority is 0.

Definition at line 119 of file System.hpp.

References priority_.

Referenced by esengine::ecs::TransformSystem::TransformSystem().

◆ shutdown()

virtual void esengine::ecs::System::shutdown ( Registry & registry)
inlinevirtual

Called once when the system is removed.

Parameters
registryReference to the ECS registry

Override to cleanup resources allocated in init().

Definition at line 88 of file System.hpp.

◆ update()

virtual void esengine::ecs::System::update ( World & world)
pure virtual

Called every frame to execute system logic.

Parameters
worldThe world context (registry, services, deltaTime)

Pure virtual - must be overridden. This is where the main system logic goes.

Implemented in esengine::ecs::TransformSystem.

Member Data Documentation

◆ enabled_

bool esengine::ecs::System::enabled_ = true
protected

Whether the system is enabled.

Definition at line 129 of file System.hpp.

Referenced by isEnabled(), and setEnabled().

◆ priority_

i32 esengine::ecs::System::priority_ = 0
protected

Execution priority (lower = earlier).

Definition at line 131 of file System.hpp.

Referenced by getPriority(), and setPriority().


The documentation for this class was generated from the following file:
  • /home/runner/work/estella/estella/src/esengine/ecs/System.hpp