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::World is the top-level container for an entire simulation. It owns every Unit in the scene through a std::vector<std::unique_ptr<Unit>>, exposes a full set of Unit management methods, and provides the play() method that starts the main game loop. Nothing runs until a World exists and play() is called.
Constructing a World
Create a World by passing a name string to its constructor. The name is stored for identification purposes.World uses
std::unique_ptr to manage every Unit it contains. You never need to manually delete a Unit — destroying the World (or letting it go out of scope) automatically cleans up all Units and their attached Modules.Managing Units
All Unit lifetime is controlled through the World. Units cannot be constructed independently and inserted — they must be created viacreateUnit().
createUnit(name)
Constructs a new Unit with the given name and pushes it into the internal worldUnits vector. If the name string is empty, the call is a no-op and a message is printed to stdout.
removeUnitByName(name)
Removes the first Unit whose getName() matches the provided string. Prints a message to stdout if no match is found.
removeUnitByIndex(index)
Removes the Unit at the given zero-based position in the internal vector.
getUnitByName(name)
Returns a std::unique_ptr<Unit>& reference to the Unit with the matching name. Use this to chain Module operations directly.
getUnitByIndex(index)
Returns a std::unique_ptr<Unit>& reference by zero-based vector position.
getUnitsVector()
Returns a const std::vector<std::unique_ptr<Unit>>& — a read-only view of all Units currently in the World. Useful for inspection or iteration without modifying the scene.
The Game Loop
play() is a const method that starts the simulation. It first checks that worldUnits is non-empty. It then iterates over Units one at a time; for each Unit whose Module list is non-empty it enters a while (true) loop — calling callModuleStart() on that Unit then sleeping 16 milliseconds before repeating. Units with no Modules print a message to stdout and are skipped.
Full Usage Example
The following example mirrors themain.cpp entry point bundled with MiniECS and demonstrates the complete World setup pattern:
Construct the World
Instantiate
MiniECS::World with a descriptive name. This allocates the internal Unit vector.Attach Modules
Use
getUnitByName() or getUnitByIndex() to reach a Unit, then call addModule() with the desired ModuleType.Configure Module state
Retrieve typed Module pointers with
getModule<T>() and set any initial values.