Components¶
A component is a plain data struct attached to an entity. It has no logic and no
Update(). Systems read and write it.
That is a complete, valid component.
Design rules¶
- Data only. No getters, setters, or update methods. Behaviour belongs in a system.
- Small and focused. Prefer
Position+Velocityover oneTransformthat also owns scale, tint, and physics. Systems subscribe to exactly what they read. - No ownership. Avoid
std::shared_ptr, raw owning pointers, and heavy containers. Components are copied, moved, and serialized; keep them cheap and value-like. - Serializable by default. The editor reflects over public fields. Use types the
reflection layer understands:
float,int,bool,std::string, enums, and nested value structs. - Stable field names. They are the keys in
.sceneand.prefabfiles.
Built-in components¶
| Component | Purpose |
|---|---|
Position |
World x, y, draw layer z, previous-frame values, moved flag, relative (follow parent delta) |
Rotation |
Angle in degrees |
ScreenSpace |
Tag: draw in window pixels, ignoring the camera (HUD) |
Parent |
Hierarchy link to another entity |
Name |
Human-readable label used by the editor and prefabs |
Opacity |
Alpha multiplier, with optional inheritance from ancestors |
SpriteComponent |
Sprite asset path, offsets, scale, flip |
ShapeComponent |
Rectangle, circle, regular polygon, or line |
Text |
String, font, size, spacing, colour |
CameraComponent |
Zoom, follow target, bounds, shake |
ColliderComponent |
Collision shape and layer/mask |
CollisionEvents |
Callbacks for collision and trigger lifecycle |
AudioSource |
Sound or music request |
Input |
Per-entity action state and player index |
ScriptComponent |
Lua script path and runtime state |
PrefabInstance |
Link back to the prefab that spawned this entity |
SignalConnections |
Subscriptions to typed signals |
NetworkComponent |
Replication flags and network identity |
PluginExampleEvents |
Example event component from the plugin sample |
Most of these have dedicated pages: Rendering, Collisions, Audio, Input, Networking, Scripting.
Tags are components too¶
A component with no fields is a tag. It carries one bit of information: "this entity is different".
ScreenSpace is the built-in example: the renderer checks for it and switches to the HUD
pass. Use tags instead of booleans on unrelated components; they compose better.
Reflection¶
Components opt into serialization through Engine/include/Reflection/ComponentReflect.hpp.
If a component is missing there, the editor cannot save it. See Scene format.
Notes on Transform¶
The engine does not have a Transform component. It uses separate Position and Rotation
components, plus Parent for hierarchy. When porting snippets, replace
Transform{ .x, .y } with Position(x, y).