The plugins a game loaded, kept loaded as long as it lives.
More...
#include <aegis2d/ecs/plugins.hpp>
The plugins a game loaded, kept loaded as long as it lives.
A plugin is an Aegis2D library (see core::LibraryInfo) that also exports a start function with C linkage, built against the same engine version:
return &info;
}
}
What a plugin can add to the game, given to its start function.
Definition plugins.hpp:20
void add_asset_folder(std::filesystem::path folder)
Adds a folder of assets the plugin brings, which the game loads like its own.
Definition plugins.hpp:32
Scheduler & systems() const noexcept
The game's systems: the plugin adds its own, e.g. systems().add("drift", ...).
Definition plugins.hpp:28
Entry point of the ECS: creates entities and stores their components.
Definition registry.hpp:34
System & add(std::string name, Args &&... args)
Builds a system in place and adds it after the others.
Definition system.hpp:118
constexpr std::uint32_t library_api_version
Version of the interface between the engine and the libraries it loads.
Definition shared_library.hpp:19
What an Aegis2D library tells about itself, from its C entry point.
Definition shared_library.hpp:36
std::uint32_t api_version
library_api_version the library was built with.
Definition shared_library.hpp:38
One simulation step, as the systems see it.
Definition system.hpp:23
The game loads them at start:
The plugins a game loaded, kept loaded as long as it lives.
Definition plugins.hpp:77
std::size_t load_folder(const std::filesystem::path &folder, PluginContext &context)
Loads every plugin of a folder, in the order of their file names.
Ordered list of named systems, all updated once per tick.
Definition system.hpp:100
std::filesystem::path executable_dir()
Folder containing the running executable.
The systems a plugin adds run the plugin's code, so the Plugins must outlive the Scheduler: declare it first. A plugin reads the game's components through the registry, which finds them by typeid: build it with the default visibility of its symbols, like the game, so that both see the same types.
◆ Plugins() [1/3]
| aegis2d::ecs::Plugins::Plugins |
( |
| ) |
|
|
default |
◆ Plugins() [2/3]
| aegis2d::ecs::Plugins::Plugins |
( |
const Plugins & |
| ) |
|
|
delete |
◆ Plugins() [3/3]
| aegis2d::ecs::Plugins::Plugins |
( |
Plugins && |
| ) |
|
|
defaultnoexcept |
◆ ~Plugins()
| aegis2d::ecs::Plugins::~Plugins |
( |
| ) |
|
|
default |
◆ load()
| std::string aegis2d::ecs::Plugins::load |
( |
const std::filesystem::path & |
path, |
|
|
PluginContext & |
context |
|
) |
| |
Loads a plugin and lets it add its systems and assets.
Checks it with core::load_library(), then calls its start function with context. The library stays loaded even if the start function throws, since it may have added systems before.
- Parameters
-
| path | Path of the plugin's library. |
| context | What the plugin can add to. |
- Returns
- The plugin's name, from its LibraryInfo.
- Exceptions
-
| core::LibraryError | if it cannot be loaded, is of another version or has no start function, or if the start function throws (with its message). |
◆ load_folder()
| std::size_t aegis2d::ecs::Plugins::load_folder |
( |
const std::filesystem::path & |
folder, |
|
|
PluginContext & |
context |
|
) |
| |
Loads every plugin of a folder, in the order of their file names.
Files whose extension is not the system's library one (.so, .dylib or .so on macOS, .dll) are skipped; a missing folder loads nothing.
- Parameters
-
| folder | Folder of the plugins, such as executable_dir() / "plugins". |
| context | What the plugins can add to. |
- Returns
- The number of plugins loaded.
- Exceptions
-
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ size()
| std::size_t aegis2d::ecs::Plugins::size |
( |
| ) |
const |
|
inlinenoexcept |
Number of plugins loaded.
- Returns
- The number of libraries kept loaded.
The documentation for this class was generated from the following file: