Documentation Index
Fetch the complete documentation index at: https://mintlify.com/raoulkdev/MiniECS/llms.txt
Use this file to discover all available pages before exploring further.
MiniECS::Unit is the entity class. It holds a collection of Modules and provides type-safe access to them. Units are not constructed directly — they are created through World::createUnit() and owned by the World. Each Unit carries a name for identification and a modules vector that drives its per-frame behaviour.
Namespace & Header
Constructor
name field) and prints "Constructed unit, name: <name>" to stdout. Units are constructed internally by World::createUnit() and stored as std::unique_ptr<Unit> — you do not normally call this constructor directly.
The name to assign to this Unit. Used for identification in
World::getUnitByName() and World::removeUnitByName().Destructor
"Destructed unit, name: <name>" to stdout when the Unit is destroyed. Because the Unit owns its Modules via unique_ptr, all attached Modules are also destroyed at this point, each printing their own "Removed <typeName>" message.
addModule
"Module type already exsists, cannot add it!" to stdout and does nothing.
The supported types and their corresponding concrete classes are:
ModuleType | Concrete Class |
|---|---|
ModuleType::Renderer | RendererModule |
ModuleType::Transform | TransformModule |
ModuleType value (such as ModuleType::ModuleBase) prints "Invalid Module Type!!" and does not add a Module.
The type of Module to create and attach. See
ModuleType for all valid values.Each Unit can hold at most one Module of each type. The duplicate check is based on the
ModuleType enum value stored inside the Module, compared via getType().removeModule
getType() matches moduleType. If found, the Module is erased from the vector and its destructor is called. If no matching Module is found, the method prints "Could not find module in: <name>" to stdout.
The type of Module to locate and remove. See
ModuleType for all valid values.getModule<T>
dynamic_cast<T*> on each Module’s raw pointer. Returns the first successful cast. If no Module in the vector can be cast to T, prints "Module of requested type not found in unit: <name>" to std::cerr and returns nullptr.
Template parameter: T — the concrete Module subclass to retrieve, such as TransformModule or RendererModule.
Returns: T* pointing to the matching Module, or nullptr if no match is found.
Example
getName
std::string — the Unit’s name.
Example
getModulesVector
modules vector. This is a lower-level accessor primarily used by World::play() to check whether a Unit has any Modules before entering the game loop. Prefer addModule(), removeModule(), and getModule<T>() for typical module management.
Returns: std::vector<std::unique_ptr<Module>>& — a mutable reference to the modules container.
Example
callModuleStart
modules vector and calls start() on each one in order. This method is invoked by World::play() on every frame (approximately every 16 ms) for Units that have at least one Module. You can also call it manually if you need to tick a Unit outside the standard game loop.
Example
The
start() name is a legacy convention from the framework’s initial design. In practice, start() functions as a per-frame update callback, not a one-time initialisation method.